----------------------------------- coolgod Wed Dec 21, 2011 11:57 pm premature optimization is the root of all evil ----------------------------------- I think this is one of my biggest flaws during major contest, i tend to optimize alot as i write the code. It especially screws me up during DWITE. My teacher says it has screwed numerous other stars in our schools before. Any any advise or suggestions to help me deal with it? An example was today for DWITE #4 i used a star and made a silly mistake somewhere, got 3/5 and wasted 1.5 hrs. Could have bfsed 5/5 it in like 20 mins. ----------------------------------- A.J Thu Dec 22, 2011 12:26 am RE:premature optimization is the root of all evil ----------------------------------- Would you mind elaborating 'optimize a lot as I write code'? As in, you try to make it memory efficient? Usually with contests, you want to be aware of the time constraints and the input specs of the problems. For example, on DWITE I never suggest implementing a breadth first search, as a depth first search could as easily solve the problem with the given constraints, and requires (well, most of the time) less code than a breadth first search. In general though, I would suggest thinking in terms of: 1) The complexity required to solve the problem (by this I mean what is the slowest program that could pass given the constraints). 2) Problem genre. This comes from experience, basically trying to recognize what 'genre' the intended solution falls under 3) Determining an Algorithm. Arguably the most challenging part. Come up with an algorithm (or implement a known one) to solve your problem 4) Implement your Algorithm. This is the part you want to try saving some precious time on, though not at the expense of complexity But I guess its always a learning curve. DWITE does help a lot with small things like this (so now in the future you'll know to implement a DFS/BFS for pathfinding problems as opposed to an A*, if appropriate). ----------------------------------- coolgod Thu Dec 22, 2011 12:31 am Re: premature optimization is the root of all evil ----------------------------------- Implement your Algorithm. This is the part you want to try saving some precious time on, though not at the expense of complexity