Problem solving on acm international collegiate programming contest
1. Problem Solving on ACM
International Collegiate
Programming Contest
Fedor Tsarev, ACM ICPC World
Champion 2008
St. Petersburg University of IT,
Mechanics & Optics
18.10.2010
ETH Zurich
3. 3
Perfect Team
Common code-style
(indents, variable naming,
…)
Common patterns of
algorithm implementation
Everyone should know
strong and weak points of
other members of the
team
4. 4
Start of the Contest
Write a template
Read problem statements:
Starting with the first
problem
Starting with the last
problem
Do not try to solve the first
problem you have read –
find the simplest problem
Every member must know
his role at the start of the
contest
6. 6
One hour from the start of the
contest…
№ Member 1 Member 2 Member 3 Comments
A
+ Graph theory
B
+ + + KMP
C
+ + + DP over subsets
D
+ + + Geometry
…
+ + +
7. 7
How to solve a problem
1. Read the statement carefully
2. Invent an algorithm
3. Discuss the algorithm with another member
of your team
4. Discuss the implementation with another
member of your team
5. Write a program
6. Test your solution
8. 8
Submitting a Solution
Save the source file before submitting
Compile it
Always test the solution on example tests and
on all tests you have:
Corner cases
Maximal tests (checking time limit and memory
limit)
Print the source code after submitting (on the
official contest)
9. 9
If your solution is not
accepted…
… then you have a bug in the program
To find it carefully read the printout
Never read the code from the screen
If you find a bug do not fix it right now on the
computer – there are more bugs in the program
Fix the bug in the printout
Try to explain your code to another member of
your team
Write a slower solution and stress-test with it
…
10. 10
Debugging
Debugging is a very time-consuming process
You do not create code while debugging
Avoid using debugger!
Read the printout instead
11. 11
Programming in Pairs
If the implementation is too difficult for you…
If you are tired…
If the code is large…
Try programming in pairs:
One of the team members writes the code
Another one is looking for mistakes
This idea is from eXtreme Programming
12. 12
Last hour of the contest
Your goal is to get “Accepted” for all
problems you have started
Do not start new problems if you have “old”
ones
If you do not have enough time for all
problems choose some of them
13. 13
Log of the contest
Only for trainings
Helps you to analyze the results of the contest
Time Member 1 Member 2 Member 3
30 Wrote a template Read A, B, C, D.
Wrote solution for
B
Read F, G, H, I
60 … … …
… … … …
300 … … …