Welcome to

Computer Programming Contest Orientation
Presented by Ahmed Shamsul Arefin The University of Newcastle, Australia


Based on a Programming Contest Training Workshop by Shahriar Manzoor (Judge, WF Contest) and Rezaul Alam Chowdhury (Faculty, State University of New York at Stony Brook). 11/6/2011 1

Part One General Information
Conduct of the Contest Computing Environment Judgment Scoring



Recap -

ACM South Pacific Regional Contest Results 2011

University of New South Wales
Team name: 13337 ViSu4L B451c PWN3RZ!11! Team Kitten Tofu Jarrah Lacko Christopher Chen

Coach Tim Lambert



Recap- Regional Top 10
Place Team University Solutions Time

2 3

13337 ViSu4L B451c PWN3RZ!11!
Brogrammers DatJoCur

University of New South Wales
University of Sydney Queensland University of Technology

8 6

1320 943

4 5 6 7 8

Pre-Raphaelite Shaolin Funrolled Loops DJ Tomato INT_MIN / -1 (red) lg(k)

University of New South Wales University of Canterbury Victoria University of Wellington University of Auckland University of New South Wales

5 5 5 5 5

414 423 458 486 665

9 10

Special Tactics UTas A

University of Western Australia University of Tasmania

5 4

885 227




Berkeley Albert-Ludwigs-Universität University of Waterloo Harvard University University of Melbourne Stanford University University of Otago Country China China Russia Russia Poland Russia China Russia Poland China Russia Russia Canada Czech Republic United States United States Freiburg. Mechanics and Optics University of Warsaw Saratov State University Shanghai Jiao Tong University Saint Petersburg State University of Information Technologies. Mechanics and Optics University of Warsaw Shanghai Jiao Tong University St. Petersburg State University St. Petersburg State University University of Waterloo Charles University Harvey Mudd College University of California.Bigger Picture (World Final) Year 2011 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 Institution Zhejiang University Shanghai Jiao Tong University Saint Petersburg State University of Information Technologies. Mechanics and Optics Saint Petersburg State University of Information Technologies. Germany Canada United States Australia United States New Zealand 6 4 4 2 2 5 .

Recap.Contest Environment Picture Source : Internet/ Google Uncle! 11/6/2011 6 .

Conduct of the Contest • Exactly eight (8) to ten(10) programming problems will be posed in English. 11/6/2011 7 . • The contest will run for five (5) hours. • Teams will try to write the solutions of the problems in any one of the programming languages allowed (C/C++. • Only one (1) computer is allocated for each team.Java) and submit for acceptance.

 Mobile phones and other communication devices. and printed program listings.Conduct of the Contest Allowed: Resource materials such as books. manuals. Prohibited:  Machine readable versions of programs or data. 11/6/2011 8 .  Calculators. laptop/palmtop computers.

11/6/2011 9 .Conduct of the Contest Prohibited: Conversation (during contest hours) with anyone (including the coach) except members of own team and system support staffs. Any activity that jeopardizes the contest.

• In any case the exact timing will be decided according to the situation. 11/6/2011 10 .Conduct of the Contest (del) Contest Duration: • The Chairman of the Program Committee has the authority to change the duration of the contest in the event of unforeseen difficulties. • In case of interruption of power for duration of less than 30 minutes. contest will continue for at least half an hour after the restoration of power (Not Applicable in AUSTRALIA).

Convenient development tools will be provided for each of the languages. All computers are networked together.Computing Environment One team. All the computers run on same operating system (Windows or Linux). one computer. C++ and Java. Programming languages allowed are : C. Solutions must be submitted to the judges through network using the PC2 judging utility. 11/6/2011 11 .

submit it for judgement. Each of your submitted runs is judged as accepted or rejected. and you will be notified of the results with full-screen messages. 12 11/6/2011 .Judgement • • If you are confident about your solution to a problem.

 Run Time Error.  Time Limit Exceeded. Rejected Solutions:  Incorrect Output. 11/6/2011 13 .Judgement Accepted Solutions: Will be notified as Correct.  Presentation Error.  No Output.

11/6/2011 14 .Judgement Correct: • Your solution must read input from a file specified in the program description and produce output to the standard output. • If the output of your program matches with what the judges expected. your solution is considered Correct. • But when the judges test your program that input file contains some additional secret data specially designed to check the correctness of a solution.

you will get an Incorrect Output notification. 11/6/2011 15 .Judgement Incorrect Output: • If the output of your program does not match with what the judges expect.

Judgement No Output: • Your program runs but does not produce any output for the judges’ secret input data.  Run time error.  Assuming incorrect input data format. Some Possible Causes:  The name or the path of the input file in your program may be written incorrectly. The input file will always be in the current directory. 11/6/2011 16 .

 Case mismatch. but does not print it in the proper format. 11/6/2011 17 .Judgement Presentation Error: • Possibly your solution produces correct output for the judges’ secret data. Some Possible Causes:  White-space and newline characters in improper numbers and positions.  Spelling mistake.

Judgement Run Time Error: • Your program performs an illegal operation when run on the judges’ input.  Overflow.  Divide by zero. 11/6/2011 18 . Some Illegal Operations:  Invalid memory access.  Domain error.

you get a TLE notification.  Infinite loop. If your program fails to do so. 19 .  Waiting for input from standard input device. Some Possible Causes:  Using an inefficient algorithm.  11/6/2011 Assuming wrong input data format.Judgement Time Limit Exceeded: • The judges allow your program to produce output for their secret data within a specific time period.

• Teams who are still tied are ranked by the earliest time of submittal of the last accepted problem.Scoring • Teams are ranked according to the most problems solved (judged Correct). • Teams who solve the same number of problems are ranked by least total penalty time. 11/6/2011 20 .

based on a different penalty value) • 11/6/2011 21 . penalty = 120 + 20  3 = 180 minutes.e.. Now.Scoring Sample Calculation: • Say a team has submitted the correct solution of a problem at the 120th minute. if they submit the correct solution of another problem at the 300th minute with 4 rejected submissions before the correct one. then total penalty = (300 + 20  4) + 180 = 380 + 180 = 560 minutes. but made 3 rejected submissions before the correct one. (This figure is illustrative. i. So.

Part Two Tips on Team Strategy Frequently Set Problems Efficient Programming Team Strategy 11/6/2011 22 .

• A strategy of co-operation with teammates.A Good Programming Team • Must have knowledge of standard algorithms and the ability to find an appropriate algorithm for every problem in the set. • Ability to code an algorithm into a working program. 11/6/2011 23 .

Frequently Set Problems Search Problems Graph Problems Geometric Problems Dynamic Programming Problems Trivial Problems Non-standard Problems 11/6/2011 24 .

 Subsequently spend a lot of time debugging. Instead:  Think carefully about the problem and all the cases which might occur. and take the time to ensure that you get it right the first time with a minimum amount of debugging. 11/6/2011 25 .Efficient Programming Does not mean:  Type as fast as you can.  Then program your algorithm.

To Become a Team Play a lot of training contests under circumstances which are as close to the real contest as possible.onlinejudge. Practice! Practice!! Practice!!! http://uva.org/ 11/6/2011 26 .

Try to divide the problems into difficulty classes: easy. hard. Be careful not to misjudge the difficulty of a problem. medium. etc. 11/6/2011 27 .Tips on Team Strategy Analyze the problem set first. Try to solve the easy problems first.

Tips on Team Strategy  Every member need not know all arts of programming but everyone must have the basic skills of programming such as writing procedures. compiling. some other dynamic programming and one should have deep knowledge of mathematics. 11/6/2011 28 . etc.  Then some may be specialized for searching. debugging. graph traversing problems.

11/6/2011 29 .Tips on Team Strategy  Every team member should know every other member’s weakness and strength so when he reads a problem he should understand who is The MAN to solve that problem.

11/6/2011 30 .Tips on Team Strategy Don’t waste much of your time with a single problem. Your team mate may find a good solution quickly for that. Try to read all problems.

” 11/6/2011 31 . Always think about the welfare of the team.Tips on Team Strategy The team members should have good understanding between them because they will have to decide when one will leave the computer. Contest is not a time to become selfish. I have finished my quota” or “I must solve one problem any how” or “I will be dropped next time. You should not think like “Oh.

 Solving problems together can also be helpful. This is also good for the team whose aim is to solve at least one problem. Thus you avoid communication overhead and the confusion caused by differing programming style. 11/6/2011 32 . This strategy works out when the question is hard.Tips on Team Strategy  The most efficient way to write a program is to write it alone.

It will be a great pity if all three man are busy with solving problems and the computer is left lonely. So computer time is extremely valuable.Tips on Team Strategy In a 5 hour contest you have 15 man hours and only 5 computer hours. 11/6/2011 33 .

11/6/2011 34 .Tips on Team Strategy  If the easiest problem of the contest is getting rejected for some silly mistakes then it is often a good idea to redo the problem (by some other member of the team).

11/6/2011 35 .Tips on Team Strategy Try to see the current standing and also find out which problem is solved most. If that problem is not solved by your team then try to solve it immediately.

When your solution gets rejected by the judges try to think about your mistakes rather than debugging on the computer. REAL TIME DEBUGGING is the ultimate Sin. analyze it and then go in front of the computer. 11/6/2011 36 .Tips on Team Strategy Use the chair in front of the computer only for typing and not for thinking. Write your program on the paper.

So you don’t get any point for a 99 % solved problem. That is why. don’t try to attack too many problems.Final Words on Strategy The Scoring system of a Contest is digital. At the end of the contest you may find that you have solved all problems 90% and your team is at the bottom of the rank list. 11/6/2011 37 .

Sample Problem I Love Big Numbers ! • • The Problem A Japanese young girl went to a Science Fair at Tokyo. your task is to help the Robot with the similar problem." Saying this.You first calculate 5!=120. "How can you tell that ?" Robot asked the girl. She asked her. Then find the sum of the digits of your result!. I can do!"Robot replied. then find sum of the digits 1+2+0=3.At this point the Robot started thinking and calculating. The Robot replied. After a few minutes the Robot head burned out and it cried out loudly "Time Limit Exceeds".Can you do it?" "Yes. what will be the result ?". you have to find out the Factorial of that number. Suppose the number is 5."Yes! I love mathematics". which had AI (You must know about AI-Artificial Intelligence). • • • • • • 38 . The girl laughed at the Robot and said "The sum is definitely 648". "Do you have any idea about maths ?". "Because I am an ACM World Finalist and I can solve the Big Number problems easily. Now. the girl closed her laptop computer and went away. she can do some fun with that Robot. There she met with a Robot named Mico-12. "Okey ! Then I am giving you a number. "Suppose the number is 100. The Japanese girl thought.

i.I Love Big Numbers ! • • • • • The Input The input file will contain one or more test cases.onlinejudge.RockFord Programming Contest) http://uva.es/ 39 . print one line containing the required number. Each test case consists of one line containing an integers n (n<=1000).e.uva. it will be less than 2^31-1. The Output For each test case.org/ http://acm. This number will always fit into an integer. • • • • • • • • Sample Input 5 60 100 Sample Output 3 288 648 -------------------------------------------------------------------------------------------------------------------Set by Ahmed Shamsul Arefin (2001.

maintained by Miguel Revilla • Light Online Judge .maintained by Xtreme Team • CodeChef . • Programming Challenges .maintained by Directi Group • Hello-World .maintained by Ahmed Shamsul Arefin (That’s me!) • Igor's UVa .maintained by Sang Song Original Slides by: Shahriar Manzoor (Judge.maintained by Jane Alam Jan • UVa Online Judge Board . • 40 .maintained by Andrian Kurniady • Codeforces blogs ICPC Training • Algorithmist .maintained by Igor Naverniouk • Andrian Kurniady's ICPC event blog . ICPC Blogs • ACMSolver .maintained by Steven Skiena.maintained by Steven Halim • The Stony Brook Algorithm Repository .maintained at Baylor University.Thanks • • • • External links (From Wikipedia) Official website Official Website of the ACM-ICPC . WF Contest) and Rezaul Alam Chowdhury (Faculty.maintained by Universidad de Valladolid Online Judge • Caribbean training platform . State University of New York at Stony Brook).maintained by Algorithmist Team • Steven Halim's Method to solve ACM UVa OJ Problems .

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.