Welcome to
Computer Programming Contest
Orientation
Presented by
Ahmed Shamsul Arefin
The University of Newcastle, Australia
11/6/2011 1
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).
Part One
General Information
Conduct of the Contest
Computing Environment
Judgment
Scoring
11/6/2011 2
Recap -
11/6/2011 3
University of New South Wales
Team name: 13337 ViSu4L B451c PWN3RZ!11!
Team
Kitten Tofu
Jarrah Lacko
Christopher Chen
Coach Tim Lambert
ACM South Pacific Regional
Contest Results 2011
Recap- Regional Top 10
11/6/2011 4
Place Team University Solutions Time
1 13337 ViSu4L B451c PWN3RZ!11! University of New South Wales 10 1025
2 Brogrammers University of Sydney 8 1320
3 DatJoCur Queensland University of Technology 6 943
4 Pre-Raphaelite Shaolin University of New South Wales 5 414
5 Funrolled Loops University of Canterbury 5 423
6 DJ Tomato Victoria University of Wellington 5 458
7 INT_MIN / -1 (red) University of Auckland 5 486
8 lg(k) University of New South Wales 5 665
9 Special Tactics University of Western Australia 5 885
10 UTas A University of Tasmania 4 227
http://www.sppcontest.org/2011/SP_Results_2011.html#Australia
Bigger Picture (World Final)
5
Year Institution Country
2011 Zhejiang University China
2010 Shanghai Jiao Tong University China
2009Saint Petersburg State University of Information
Technologies, Mechanics and OpticsRussia
2008Saint Petersburg State University of Information
Technologies, Mechanics and OpticsRussia
2007 University of Warsaw Poland
2006 Saratov State University Russia
2005 Shanghai Jiao Tong University China
2004Saint Petersburg State University of Information
Technologies, Mechanics and OpticsRussia
2003 University of Warsaw Poland
2002 Shanghai Jiao Tong University China
2001 St. Petersburg State University Russia
2000 St. Petersburg State University Russia
1999 University of Waterloo Canada
1998 Charles University Czech Republic
1997 Harvey Mudd College United States
1996 University of California, Berkeley United States
1995 Albert-Ludwigs-Universität Freiburg, Germany
1994 University of Waterloo Canada
1993 Harvard University United States
1992 University of Melbourne Australia
1991 Stanford University United States
1990 University of Otago New Zealand
4
6
4
2 2
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.
11/6/2011 8
Allowed:
Machine readable versions of programs
or data.
Calculators, laptop/palmtop computers.
Mobile phones and other communication
devices.
Prohibited:
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.
11/6/2011 9
Prohibited:
Conduct of the Contest (del)
• 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
Contest Duration:
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 judgesthrough network using the PC2 judging utility.
11/6/2011 11
Judgement
• 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.
11/6/2011 12
Judgement
Will be notified as Correct.
11/6/2011 13
Accepted Solutions:
Incorrect Output.
No Output.
Presentation Error.
Run Time Error.
Time Limit Exceeded.
Rejected Solutions:
Judgement
• Your solution must read input from a filespecified 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
Correct:
Judgement
• If the output of your program does not
match with what the judges expect, you
will get an Incorrect Output notification.
11/6/2011 15
Incorrect Output:
Judgement
• Your program runs but does not produce any output for the judges’ secret input data.
11/6/2011 16
No Output:
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.
Judgement
• Possibly your solution produces correct
output for the judges’ secret data, but
does not print it in the proper format.
11/6/2011 17
Presentation Error:
Some Possible Causes:
White-space and newline characters in
improper numbers and positions.
Spelling mistake.
Case mismatch.
Judgement
• Your program performs an illegal operationwhen run on the judges’ input.
11/6/2011 18
Run Time Error:
Some Illegal Operations:
Invalid memory access.
Divide by zero.
Overflow.
Domain error.
Judgement
• 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.
11/6/2011 19
Time Limit Exceeded:
Some Possible Causes:
Using an inefficient algorithm.
Infinite loop.
Waiting for input from standard input
device.
Assuming wrong input data format.
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.
• Teams who are still tied are ranked by the
earliest time of submittal of the last
accepted problem.
11/6/2011 20
Scoring
• 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.
11/6/2011 21
Sample Calculation:
(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
11/6/2011 22
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.
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
Efficient Programming
Type as fast as you can.
Subsequently spend a lot of time debugging.
11/6/2011 25
Does not mean:
Instead:
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.
To Become a Team
11/6/2011 26
Play a lot of training contests under
circumstances which are as close to the
real contest as possible.
Practice! Practice!! Practice!!!
http://uva.onlinejudge.org/
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.
11/6/2011 27
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.
11/6/2011 28
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 29
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 30
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.
11/6/2011 32
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.
11/6/2011 33
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 34
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.
11/6/2011 35
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.
11/6/2011 36
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.
11/6/2011 37
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.
38
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/39
Thanks • 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).40