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




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, 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, 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, Germany Canada United States Australia United States New Zealand 6 4 4 2 2


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. • Only one (1) computer is allocated for each team. • 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++,Java) and submit for acceptance.
11/6/2011 7

Conduct of the Contest
Resource materials such as books, manuals, and printed program listings.

 Machine readable versions of programs

or data.  Calculators, laptop/palmtop computers.  Mobile phones and other communication devices.
11/6/2011 8

Conduct of the Contest
Conversation (during contest hours) with anyone (including the coach) except members of own team and system support staffs. Any activity that jeopardizes the contest.



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). • In any case the exact timing will be decided according to the situation.
11/6/2011 10

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


• •

If you are confident about your solution to a problem, 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.


Accepted Solutions:
Will be notified as Correct.

Rejected Solutions:
 Incorrect Output.  No Output.

 Presentation Error.
 Run Time Error.  Time Limit Exceeded.
11/6/2011 13

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

Incorrect Output:
• If the output of your program does not match with what the judges expect, you will get an Incorrect Output notification.



No Output:
• Your program runs but does not produce any output for the judges’ secret input data.

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.  Assuming incorrect input data format.  Run time error.
11/6/2011 16

Presentation Error:
• Possibly your solution produces correct output for the judges’ secret data, but does not print it in the proper format.

Some Possible Causes:
 White-space and newline characters in

improper numbers and positions.  Spelling mistake.  Case mismatch.
11/6/2011 17

Run Time Error:
• Your program performs an illegal operation when run on the judges’ input.

Some Illegal Operations:
 Invalid memory access.

 Divide by zero.
 Overflow.  Domain error.



Time Limit Exceeded:
• The judges allow your program to produce output for their secret data within a specific time period. If your program fails to do so, you get a TLE notification.

Some Possible Causes:
 Using an inefficient algorithm.
 Infinite loop.  Waiting for input from standard input

device.  11/6/2011 Assuming wrong input data format.


• 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. • Teams who are still tied are ranked by the earliest time of submittal of the last accepted problem.



Sample Calculation:
• Say a team has submitted the correct solution of a problem at the 120th minute, but made 3 rejected submissions before the correct one. So, penalty = 120 + 20  3 = 180 minutes. Now, 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.
(This figure is illustrative, i.e., based on a different penalty value)



Part Two Tips on Team Strategy
Frequently Set Problems Efficient Programming Team Strategy



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. • A strategy of co-operation with teammates.



Frequently Set Problems
Search Problems Graph Problems Geometric Problems Dynamic Programming Problems Trivial Problems Non-standard Problems



Efficient Programming
Does not mean:
 Type as fast as you can.  Subsequently spend a lot of time debugging.

 Think carefully about the problem and all

the cases which might occur.  Then program your algorithm, and take the time to ensure that you get it right the first time with a minimum amount of debugging.
11/6/2011 25

To Become a Team
Play a lot of training contests under circumstances which are as close to the real contest as possible. Practice! Practice!! Practice!!!



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



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, debugging, compiling.  Then some may be specialized for searching, graph traversing problems, some other dynamic programming and one should have deep knowledge of mathematics, etc.



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.



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.



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. Always think about the welfare of the team. Contest is not a time to become selfish. You should not think like “Oh, I have finished my quota” or “I must solve one problem any how” or “I will be dropped next time.”
11/6/2011 31

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



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



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).



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.



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, analyze it and then go in front of the computer. 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.



Final Words on Strategy
The Scoring system of a Contest is digital. So you don’t get any point for a 99 % solved problem. That is why, don’t try to attack too many problems. 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.



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

• • • • •


I Love Big Numbers !
• • • • • The Input The input file will contain one or more test cases. Each test case consists of one line containing an integers n (n<=1000). The Output For each test case, print one line containing the required number. This number will always fit into an integer, i.e. it will be less than 2^31-1.

• • • •
• • • •

Sample Input 5 60 100
Sample Output 3 288 648

-------------------------------------------------------------------------------------------------------------------Set by Ahmed Shamsul Arefin (2001- RockFord Programming Contest) http://uva.onlinejudge.org/ http://acm.uva.es/

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


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.