Many times, I get WA but don't know where to start when debugging, do you guys have a test case generator? Or something like that? Thanks!
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | adamant | 157 |
6 | awoo | 157 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | djm03178 | 153 |
Many times, I get WA but don't know where to start when debugging, do you guys have a test case generator? Or something like that? Thanks!
Name |
---|
I am not too experienced, but here are my two cents:
1) Think of corner cases that your solution misses — WA usually means you have missed an edge case. If it is a WA on an early test case (I get WA on test 2 a lot), then you can improvise a test case without having to spare too much time. 2) Otherwise, be creative. Try to think of something new — what you haven't thought of yet. If your mind is on a clean slate (you can't think of anything — this happens to me a lot), take a break. Try another problem (if you are in a contest).
Hope this helps!
Actually first i try to look at the constraints.Let our constraints be 0<=n<=100.Then i try to check with a test case where n=0.Also i try to check my whole code whether i have done a silly mistake.You can print the values of variables at several stages to check if they are giving anything wrong.Or you can use debuggers.There are some online debuggers like GDB.For TLE you can use test case generator to check your solutions with larger input.
I just read the WA code again and again and it works most of the times.
I only recommend doing this if you're in a pinch, but a stress tester can come in handy. Assuming the brute force version is trivial, test a bunch of small cases you can debug by hand and compare these two versions. I've only started doing this recently and it's already saved me on two separate occasions.
Search for corner cases Initially. If there aren't any corner cases, verify the solution once again. and at last, compare your solution with bruteforce for smaller cases.