At the end of today's contest after solving A-E, I was like "yay, finally, 2200+". But as system testing ended, my submission for D got FSTed (I still don't know why). Moreover, It seems like it's the only FST for problem D in the entire contest, which makes it even more disappointing. I don't know how to feel about this, maybe I invented new ways to fail system testing?








Lol I just wrote the same thing:P
that's weird cuz they said in an announcement that "In problems A-D, system tests are equal to pretests."
maybe it was a cosmic ray
As I know, there are some gaps between the environment of PT and ST. Danger optimization, undefined behaviour can change the result of execution between PT and ST(e.g. I got FST with Ofast)
Same, I got FST on problem B which left me extremely confused. Is this a new ragebait method?
The following part of your code is suspicious:
because the actual limit of $$$n$$$ is $$$n \le 3 \cdot 10^5$$$.
Buffer overflow makes your program's behavior unpredictable, and it's possible that your code gave the correct answer in pretest by chance.
But I never used
fin my code, the constraints on $$$n$$$ should not really matterYeah, you are right! It turns out your code has more subtle buffer overflow.
I tried to compile your code with extra checks(*) and found the line 117 has buffer overflow:
This can be triggered with the sample input — your code tries to access
j = 1(2nd) element ofind[i], which has only one element.(*) I always try to compile my code with the following flags (on Linux), to enable extra checks that detect out-of-bounds accesses, integer overflow etc.
Yeah, looks like it. I have no idea how that passed pretests. I changed
j -> j-1, and now it's ACThanks, your comment finally made me setup sanitizers. Are there any other flags you use? Maybe,
-O2for estimating the run time of your solution for tight cases?All the flags I currently use are listed above. I normally use
-O0to make debugging with gdb easier — this is sufficiently fast for small inputs. When I need to check performance with large inputs, I remove all those flags for checking and just use-O2. I have a tiny script that compiles a file with one of those sets of flags, so I don't have to copy-paste each of those flags manually and I can switch debug mode/performance mode easily.