--Rem--'s blog

By --Rem--, history, 23 months ago, In English

What to do when solution’s idea is right, but code fails on large test. How to find the bug?

  • Vote: I like it
  • +5
  • Vote: I do not like it

| Write comment?
»
23 months ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

You should consider your previous experience with bugs and how to fix them. For example:

  1. Overflow (long long VS int)
  2. Using the wrong mod (998244353 vs 1000000007)
  3. ...

I also recommend using assert function as possible as you can so you know if your code works properly or not. In this case, when I get the wrong answer verdict I am almost sure that my solution is not correct and the mistake is not about my bad implementation.

When you can't figure out where the bug is you can do stress testing on your solution, if you have enough time, to get a test case that makes your solution fail.

»
23 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Do a stress test and try to find a smaller test case which fails.