Блог пользователя Sayachyan

Автор Sayachyan, история, 15 месяцев назад, По-английски

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

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
15 месяцев назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

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.

»
15 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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