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 | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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.