ACM-HK Local Contest 2009 Special trainings: 6:30 - HW311 May 27, 2010 (Thur) June 3, 2010 (Thur) June 10, 2010 (Thur) Competition date: June 12,

Slides:



Advertisements
Similar presentations
Chapter 2: Basic Elements of C++
Advertisements

Introduction to Programming Lecture 34. In Today’s Lecture Arrays of objects Arrays of objects Interaction of Arrays with Free Store Interaction of Arrays.
Advanced Algorithm Design and Analysis (Lecture 6) SW5 fall 2004 Simonas Šaltenis E1-215b
The Princeton Egg The Global Consciousness Project (video)The Global Consciousness Project (video) Princeton Egg Website Our Egg: PrincetonEgg.cppPrincetonEgg.cpp.
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Input/Output Main Memory istream ostream Disk Drive Keyboard Scanner Disk Drive Monitor Printer stream = sequence of bytes.
Longest Common Subsequence (LCS) - Scoring Dr. Nancy Warter-Perez June 25, 2003.
Distance Functions for Sequence Data and Time Series
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
Computer Science 1620 Programming & Problem Solving.
Computer Science 1620 Arrays. Problem: Given a list of 5 student grades, adjust the grades so that the average is 70%. Program design: 1. read in the.
1 Random numbers Random  completely unpredictable. No way to determine in advance what value will be chosen from a set of equally probable elements. Impossible.
1 CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
Classes and Objects Objects of class type string Input/Output Objects and Formatted Input/Output 6/30/2015MET CS 563--Fall A. Using Class Type Objects.
1 9/26/07CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
1 Lecture 7 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Chapter 3: Input/Output
© Copyright 2013 by Pearson Education, Inc. All Rights Reserved.1 Chapter 4 Mathematical Functions, Characters, and Strings.
Copyright © 2012 Pearson Education, Inc. Chapter 3: Expressions and Interactivity.
Lecture 6: Expressions and Interactivity (Part II) Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Formatting, Casts, Special Operators and Round Off Errors 09/18/13.
CSC 270 – Survey of Programming Languages C++ Lecture 1 : C++ As A Better C.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 3 Selections.
CSIS 113A Lecture 5 Random Numbers, while, do-while.
Output Formatting No, I don't want 6 digits…. Standard Behavior Rules for printing decimals: – No decimal point: prints as 1 – No trailing zeros:
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 3 Formatting Output.
C++ Programming Lecture 10 Functions – Part II
C++ Streams Lecture-2. C++ Streams Stream  A transfer of information in the form of a sequence of bytes I/O Operations:  Input stream: A stream that.
Input/Output Sujana Jyothi C++ Workshop Day 2. C++ I/O Basics 2 I/O - Input/Output is one of the first aspects of programming that needs to be mastered:
Loops Wrap Up 10/21/13. Topics *Sentinel Loops *Nested Loops *Random Numbers.
CS221 Random Numbers. Random numbers are often very important in programming Suppose you are writing a program to play the game of roulette The numbers.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Provinci summer training 2010 June 17: Recursion and recursive decent parser June 24: Greedy algorithms and stable marriage July 1: Holiday July 8: Math.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 9, 2005 Lecture Number: 6.
Chapter 2 C++ self study 2nd Semester
Operating System Using setw and setprecision functions Using setiosflags function Using cin function Programming 1 DCT
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
More Sequences. Review: String Sequences  Strings are sequences of characters so we can: Use an index to refer to an individual character: Use slices.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
1 Manipulators manipulators are used only in input and output statements endl, fixed, showpoint, setw, and setprecision are manipulators that can be used.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
CSE202: Lecture 13The Ohio State University1 Function Scope.
Dynamic Programming (Edit Distance). Edit Distance Input: – Two input strings S1 (of size n) and S2 (of size m) E.g., S1 = ATTTCTAGTGGGTAAA S2 = ATCTAGTTTAGGGATA.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
1 Generating Random Numbers Textbook ch.6, pg
MR. CRONE Generating Random Numbers. Random Numbers Many programs require the computer to generate random numbers Random numbers are used in many applications.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
1 Chapter 3 Numeric Types, Expressions, and Output Dale/Weems/Headington.
Dynamic Programming for the Edit Distance Problem.
Classes and Function Members
Chapter 3 Selection Statements
C++ Basic Input and Output (I/O)
Chapter 3 L7.
Chapter 2 Assignment and Interactive Input
Distance Functions for Sequence Data and Time Series
Chapter 2 part #3 C++ Input / Output
Chapter 2 – Getting Started
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Random Number Generation
Starting Out with C++: From Control Structures through Objects
Basic Input and Output C++ programs can read and write information using streams A simple input stream accepts typed data from a keyboard A simple output.
Scientific Notation.
Screen output // Definition and use of variables
Chapter 3 Input output.
Chapter 2 part #3 C++ Input / Output
Java: Variables, Input and Arrays
Programming Fundamental-1
Presentation transcript:

ACM-HK Local Contest 2009 Special trainings: 6:30 - HW311 May 27, 2010 (Thur) June 3, 2010 (Thur) June 10, 2010 (Thur) Competition date: June 12, 2010 (Sat)

Today's training Try the problems last year (2009) Each team please use 1 machine only Spend 20 mins to read the questions, tell me who will do which question.

Some clarifications needed 1. Question B: How large is x and y? Assume x, y <= 100,000; 2. How many test cases? Assume 10 for each problem.

Problem F. Edit distance Well-known example for dynamic programming. Let S[1..m] and T[1..n] be the two input strings. Let dist[i][j] be the edit distance from S[1..i] to T[1..j] (the min steps to change S[1..i] to T[1..j]) AGCG A G C T G Observations. 1. If i==0 or j==0, dist[i][j] = non- zero index. 2. How to convert S[i] to T[j]? 1. Match them: dist[i][j] = dist[i-1][j-1] 2. Substitute S[i] by T[j]: = dist[i-1][j-1] Delete S[i]: = dist[i-1][j] Insert T[j]: = dist[i][j-1] + 1 By trying all 4 cases, I must be able to find the optimal way to change S to T!

Two extensions 1. After filling the table, how to find the steps to change S to T? AGCG A G C T G 2. Given S[1..m] and T[1..n], a subsequence of S is a sequence obtained by deleting some char. A common subsequence is a subsequence common to both S and T. How to find the length of the longest common subsequence? 3. Assignment: UVA 164, 10192, 10066

Problem D. Simulation #include int main () { /* initialize random seed: */ srand ( time(NULL) ); /* generate secret number: */ cout << rand() % ; }

Problem D. Formating #include using namespace std; int main () { double f = ; cout << fixed; cout << setprecision (3) << f << endl; cout << setprecision (9) << f << endl; } setprecision(n): print n decimal places fixed: print trailing zero Rounding? It tries to do 4-down 5-up, but may be incorrect due to precision error. (e.g., > 3.3, but > 5.2) To be save: add 0.05 first if you need to be correct to 1 decimal place.

Problem E. Flood fill UVA 469, 572