Please read the new rule regarding the restriction on the use of AI tools. ×

Tackling tricky problems

Revision en3, by VastoLorde95, 2015-06-17 22:25:14

Hi, I am sure we have all come across those problems that have these simple problem statements but are just diabolical to get right. Problems which give you moments like these

These problems are usually hard to get right for the following reasons:

  1. Corner test cases
  2. Tricky implementation

Typically problems which involve string manipulation, geometry or problems involving decimal precision are hard to get right in the first go without overlooking some minute details. Sometimes these problems require carefully breaking it up into cases.

Recently I solved the following problem and had 4 failed attempts before finally getting it right. In a competition, you might spend a ton of time trying to identify your bugs and that can make or break your final rank in the contest.

So here is what I want to ask the top programmers in the community -

  1. How do you approach such problems during live contests? I have seen many top programmers getting AC on such problems in the first try. (Usually their code is short, simple and consistent with the cases)
  2. How do you test your code to ensure that you have not missed any corner test case?
  3. In case the implementation is long and taxing, what is your approach to keep the code neat and simple?
  4. How much time do you invest in such problems before deciding they are too risky to solve in a live contest?

Thanks!

Tags implementation, codeforces, corner, case

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English VastoLorde95 2015-06-18 11:19:21 1199
en3 English VastoLorde95 2015-06-17 22:25:14 112
en2 English VastoLorde95 2015-06-17 22:20:40 8 Tiny change: 'these:\n![ ](http://i' -
en1 English VastoLorde95 2015-06-17 22:18:41 1385 Initial revision (published)