Tips & Tricks

it2024-10-29  10

From: usaco training

Tips & Tricks

Brute force it when you canKISS: Simple is smart!Hint: focus on limits (specified in problem statement)Waste memory when it makes your life easier (if you can get away with it)Don't delete your extra debugging output, comment it outOptimize progressively, and only as much as neededKeep all working versions!Code to debug: whitespace is good,use meaningful variable names,don't reuse variables,stepwise refinement,COMMENT BEFORE CODE.Avoid pointers if you canAvoid dynamic memory like the plague: statically allocate everything.Try not to use floating point; if you have to, put tolerances in everywhere (never test equality)Comments on comments: Not long prose, just brief notesExplain high-level functionality: ++i; /* increase the value of i by */ is worse than uselessExplain code trickeryDelimit & document functional sectionsAs if to someone intelligent who knows the problem, but not the codeAnything you had to think aboutAnything you looked at even once saying, "now what does that do again?"Always comment order of array indicesKeep a log of your performance in each contest: successes, mistakes, and what you could have done better; use this to rewrite and improve your game plan!

转载于:https://www.cnblogs.com/demote/archive/2012/11/14/2770240.html

最新回复(0)