Hello coders! I am sure all of you would have faced a "Wrong answer on pretest 2" at some point of time during your codeforces journey. It is a pretty frustrating feeling when you see your ranks (or ratings) dropping by a significant amount only due to some edge cases which you could not figure out during the contest time.. But the question that then comes to one's mind is : "Am I that dumb to not have figured it out then?.. and is there a way to make sure it doesn't happen a second time?" Well the answer is both a yes and no. So if you're someone struggling in the range between 1000-1400 (or even lower) then you might find this blog helpful!
Actually, for the past few weeks this has been a major concern for me because either during contests or even while practicing I used to get a lot of "Wrong answer on test 2" and when I used to check for the case where I went wrong.. Most of the times it used to return something like "786th token doesn't match". Now how on Earth am I to figure out where my code is going wrong because the 786th input is not visible to me.. Right?! What you actually can do is the following:
First thing, don't get demotivated by it because even the top coders aren't completely immune to it.. But one can definitely reduce it's frequency or reduce the time of getting their solution "accepted" after a "wrong ans on pretest 2" by immense practice.
Talking about problems A and B (#div.2) — the problems aren't complicated.. so the reason of getting a wrong ans mostly is because sometimes our approach to a question may be correct but the way we implement our solution may involve unnecessary complications (in terms of usage of multiple and unnecessary data structures or variables)..
So one can try to think of a particular problem in the simplest way possible (both in terms of approach and implementation). And I would recommend not to check what went wrong in your submission immediately after the verdict (while practicing). Instead try to first exploit all the possible edge cases that might have occurred or maybe try to reduce the unnecessary complications that ur solution might be having. And after making the necessary changes in ur soln, try resubmitting. In many of the cases you will get an "Accepted" verdict.
Suppose if you don't get it, then look at the test case which the system displays (where ur soln would have gone wrong) .. try correcting it! If it shows something like [786th tokens don't match].. then don't just get frustrated and leave the question then and there... if you are mentally too exhausted with that problem then bookmark it and move to the next problem but after say 3-5 hours (in your recess period) try to think what could have possibly gone wrong in your solution (even if you don't get an "Accepted" verdict, it still is a good exercise.
After all this, look at a friend's code who got an "Accepted" verdict or if you can make a difference between your way of implementation and the editorial, even that works fine!!
Now the reason why I want you to refrain from immediately checking the editorial or referring to a youtube tutorial on that question is because, this way you won't build your logic and implementation skills and the next time you sit for another contest a "wrong answer on pretest 2" is bound to happen again.
NOTE : This tip might not prove very effective for those high up in the ratings or maybe for those who don't have much time to devote to Competitive programming. But for beginners this will definitely boost up your ratings and improve your problem-solving approach!
Hope this helps!
I would like to give one advice which I use generally :
Agree with everything