Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

1 ACM Programming Contest Nov 3, Introduction ACM organized such contests from1977 Contest Regional Qualifying Final Purpose provides college.
ACM Programming Team Bill Punch. ACM Programming Contest One of the premier programming competitions. Held every year since 1977 MSU was the winner that.
22C:19 Discrete Structures Induction and Recursion Spring 2014 Sukumar Ghosh.
CS 410 Applied Algorithms Applied Algorithms Lecture #7 Counting.
22C:19 Discrete Structures Induction and Recursion Fall 2014 Sukumar Ghosh.
Zhang Hongyi CSCI2100B Data Structures Tutorial 2
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Recursion. Objectives At the conclusion of this lesson, students should be able to Explain what recursion is Design and write functions that use recursion.
Local Programming Contest Overview John Paxton October 25, 2006.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
Introduction to Computer Science Exam Information Unit 20.
HKOI Final 2012 Contest. Submission Submit your source code, not executable! Submit through web interface Only your last submission count.
EPFL ACM ICPC Qualifiers Program Committee I&C, EPFL.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Introduction Algorithms and Programming. Computer Programming  A form of problem solving  Or, more accurately, a way to solve problems  What we will.
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
Group practice in problem design and problem solving
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
6 Steps of the Programming Process
1 Project 5: Median. 2 The median of a collection of numbers is the member for which there are an equal number less than or equal and greater than or.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
Simple Program Design Third Edition A Step-by-Step Approach
General Programming Introduction to Computing Science and Programming I.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Recursion Textbook chapter Recursive Function Call a recursive call is a function call in which the called function is the same as the one making.
Python – Part 1 Python Programming Language 1. What is Python? High-level language Interpreted – easy to test and use interactively Object-oriented Open-source.
1 Debugging. 2 A Lot of Time is Spent Debugging Programs Debugging. Cyclic process of editing, compiling, and fixing errors. n Always a logical explanation.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
What does a computer program look like: a general overview.
1. The Role of the Algorithms in Computer Algorithms – 1/2 Algorithm: Any well-defined computation procedure that takes some value, or set of values,
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Halting Problem Introduction to Computing Science and Programming I.
CSC Programming I Lecture 6 September 4, 2002.
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
Intro to Nested Looping Intro to Computer Science CS1510 Dr. Sarah Diesburg.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
Reactive and Output-Only HKOI Training Team 2006 Liu Chi Man (cx) 11 Feb 2006.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Ch 1 - Introduction to Computers and Programming Hardware Terminology Main Memory Auxiliary Memory Drives Writing Algorithms Using Pseudocode Programming.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
1 Trees What is a Tree? Tree terminology Why trees? What is a general tree? Implementing trees Binary trees Binary tree implementation Application of Binary.
Efficiently Solving Computer Programming Problems Doncho Minkov Telerik Corporation Technical Trainer.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Online Judge System Tom Chao Zhou CSC2100B Data Structures Tutorial 2.
1 1 Chapter 2 Elementary Programming. 2 2 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from.
1 Project 5: Leap Years. 222 Leap Years Write a program that reads an integer value from the user representing a year and determines if the year is a.
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
Introduction to Computing Systems and Programming Programming.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
First Program  Open a file  In Shell  Type into the file: 3  You did it!!! You wrote your first instruction, or code, in python!
Recursion. Objectives At the conclusion of this lesson, students should be able to Explain what recursion is Design and write functions that use recursion.
Introduction to Exceptions in Java CS201, SW Development Methods.
Tisigram 2016 Technical Meeting Tuesday, March 28 th, 2016.
1 Project 12: Cars from File. This is an extension of Project 11, Car Class You may use the posted solution for Project 11 as a starting point for this.
Richard P. Simpson Midwestern State University
Some Basics for Problem Analysis and Solutions
Introduction to Computer Programming
Intro to Nested Looping
Recitation Outline C++ STL associative containers Examples
SCIENCE ON FRIDAYS.
Intro to Nested Looping
Programming Assignment Tutorial
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Contest format 5 hours, around 8-12 problems One computer running (likely)Linux, plus printer 3 people on one machine No cell phones, calculators, USB drives, Internet (C++ STL available, cplusplus.com and java api’s are available) All the paper resources you want, including books, print outs of code, anything! – If it fits in the van, bring it!

Scoring Sorted first by number of problems solved Then sorted by time – If you submit a problem at :30 and one at 1:30, your total time is 120 minutes – Find the easy problems and do them first!!! – Watch the standings and see what other teams are doing! – 20 minute penalty for wrong answer on a single submission, but it’s only counted if you eventually solve that problem

Submitting You will receive one of several responses: – Format error – Time limit reached – Runtime error (division by 0, out of memory, exception thrown, etc.) – Compile error – Wrong answer – Correct! The judges only give you one at a time – If you have two or more problems, you’ll usually only get the more embarrassing of them

Always have someone typing Typing and compiling is time intensive, and there’s only one keyboard – If your program isn’t working, print it and debug it by hand – Let someone else sit and type! If you’re waiting for the computer, write some code out by hand or ask a neighbor for their opinion on your algorithm If it has you read until end of input, use: while (cin >> x)

Questions You can submit questions to the judges about problems Updates will be given to everyone if there is a typo or other error You will get one of two responses: – A clarification – No answer (i.e. read the problem more closely)

Test the judge’s input They give you 1 or 2 sample inputs and solutions; test them! – There will normally be simple cases. Make sure your format exactly matches the judge’s sample output! – They use a file compare (via a script) so it must be very close

End cases The judges are very tricky with their tests If the problem says inputs will be between A and B, you can almost bet that inputs of size A and B will be tested Be wary of carefully worded questions!

Tree or not a tree A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties: – There is exactly one node, called the root, to which no directed edges point. – Every node except the root has exactly one edge pointing to it. – There is a unique sequence of directed edges from the root to each node.

Counting characters in a range Input will consist of two integers, 0 < N < 100 For each of the numbers in between these two numbers (inclusive), count the occurrences of each digit Example: – – 0=>17=>1 1=>48=>1 2=>29=>1 cin >> a >> b; for (i = a; i <= b; ++i) { ++arr[i / 10]; ++arr[i % 10]; } ? ?

Be generous with your memory! Make your arrays twice as big as necessary – Off by one error are difficult to find! Use the STL (strings, vectors, everything!) Use long long instead of int Use double instead of float

Code quickly at the cost of efficiency The faster you type, the faster you submit! Use the STL if it makes it easier for you – If you can’t remember how to use the STL sort, write a simple (bubble?)sort. Who cares! Generally, if you get a “time limit reached”, your algorithm needs to be changed, not just little things in your code

Helpful suggestion Bring printed code, such as the algorithms we’ll talk about. You won’t have to remember them and know you have a working/correct version too. – If someone is not typing in an answer, type in the algorithm so the template is ready to use. – Also data structures you may want to use (trees for example). – Including a “read a file” code. You know it works, then one least thing to think about.

math Number theory – Very popular in the program contests – For ICPC, you need a rather small but useful set Prime table generation, primality testing, greatest common divisor, modular arithmetic and congruence (solving linear congruences), and Euler’s – A Note, Java’s BigInteger class has a number of number-theoretic functions, like gcd, modular exponentiation, primality testing, etc.

String manipulation There have been a number of string manipulation questions over the years. Learn the string library – At the least substring, replace, find etc. – Regex maybe really helpful.

algorithms Brute force algorithms – From nested loop algorithms to backtracking (easier with recursion). Breath first search. Depth first search is recursive and has nice bracktracking features. Dynamic Programming – Recursive algorithm that is composed of subproblems Coin flipping and fibonacci are simple examples Longest Common Subsequence (LCS), Longest Increasing Subsequence (LIS), Optimal Binary Search tree (OBST), 0-1 knapsack, edit distance, Matrix Chain Product are increasing harder examples.

algorithms Trees and priority queues, not necessary an algorithms, but can speed things up. Graph theory – How to represent things and then use BFS and DFS, and topological sorting. Does the graph have cycles?

Classic Problems algorithms Shortest paths (Dijkstra for example) Spanning trees (Prim or Kruskal) Eulerain paths and circuits Matchings in bipartite graphs Network flow (max flow, min cost flows) Geometry.

STL: Deque #include deque x; x.push_back(20); x.pop_back(); x.back(); x.push_front(20); x.pop_front(); x.front(); x.resize(100); x[10] OR x.at(10); x.clear();

STL: Strings #include string str; string str(“foo”); string str(10, ‘c’); str += “bar”; Find – str.find(“aaba”); str.rfind(“aaba”); – str.find_first_of(“AEIOU”); – str.find_last_not_of(“AEIOU”, 5); – Returns an int, or string::npos if none found str.substr(int position, int length)

STL: Algorithms #include swap(a, b); // Any type that has = can go here! reverse(arr, arr + 10); reverse(deq.begin(), deq.end()); Sorting – sort(arr, arr + 10); sort(deq.begin(), deq.end()); – sort(arr, arr + 10, lessThanFunction); bool lessThanFunction(const Type& t1, const Type& t2) { if (t1 < t2) return true; return false; }

STL: Algorithms #include Permutations int x[] = {3, 5, 4, 1, 2}; sort(x, x + 5); do { // stuff } while (next_permutation(x, x + 5));

STL: formatting #include double d = ; cout << d << endl; cout << setprecision(3) << d << endl; cout << setprecision(3) << fixed << d << endl; cout << setprecision(1) << fixed << 0.55 << endl; int i = 42; cout << hex << i << endl; cout << hex << uppercase << i << endl; cout << i << endl; cout << dec << i << endl; e a 2A 42

Algorithms Brush up on – depth-first search, breadth-first search (or just use iterative deepening DFS) N-Trees, but lots of other uses as well. minimum spanning trees ing_tree – Lots of varying algorithms listed at the bottom of the page

Algorithms (2) shortest path, like Dijkstra’s algorithm – – em (Max) flow problems – u.ac.jp/~ikeda/suuri/maxflow/Maxflow.shtml Good demo of max flow and min cut algorithms. Also links to some other versions of spanning tree algorithms.

Algorithms (3) Greatest common divisor is a fun one to remember too – And remember, if gcd(a, b) == 1, then a and b are relatively prime!

Dynamic programming/memoization Recursive algorithm that is composed of subproblems – You keep recomputing the subproblems! – Save them in an array and look them up – Start with the recursive version first, then modify it to save work Examples – Fibonacci – Coin problem

Geometric algorithms

Geometric algorithms Intersection – Four points: a1, a2, b1, b2 – Compute: dir1 = direction(b1, b2, a1) dir2 = direction(b1, b2, a2) dir3 = direction(a1, a2, b1) dir4 = direction(a1, a2, b2) – If dir1/dir2 are opposite signs, and dir3/dir4 are opposite signs, they intersect

a1 a2 b1 b2 dir1 dir2 dir3 dir4 a1 a2 b1 b2 dir1 dir2 dir3 dir4