回帖:以下是原文
Crafting Winning Solutions
A good way to get a competitive edge is to write down a game plan for what you're going to do in a contest round. This will help you script out your actions, in terms of what to do both when things go right and when things go wrong. This way you can spend your thinking time in the round figuring out programming problems and not trying to figure out what the heck you should do next... it's sort of like precomputing your reactions to most situations.
Mental preparation is also important.
Game Plan For A Contest Round
Read through ALL the problems FIRST; sketch notes with algorithm, complexity, the numbers, data structs, tricky details, ...
Brainstorm many possible algorithms - then pick the stupidest that works!
DO THE MATH! (space & time complexity, and plug in actual expected and worst case numbers)
Try to break the algorithm - use special (degenerate?) test cases
Order the problems: shortest job first, in terms of your effort (shortest to longest: done it before, easy, unfamiliar, hard)
Coding a problem - For each, one at a time:
Finalize algorithm
Create test data for tricky cases
Write data structures
Code the input routine and test it (write extra output routines to show data?)
Code the output routine and test it
Stepwise refinement: write comments outlining the program logic
Fill in code and debug one section at a time
Get it working & verify correctness (use trivial test cases)
Try to break the code - use special cases for code correctness
Optimize progressively - only as much as needed, and keep all versions (use hard test cases to figure out actual runtime)
Time management strategy and "damage control" scenarios
Have a plan for what to do when various (foreseeable!) things go wrong; imagine problems you might have and figure out how you want to react. The central question is: "Whe