GVZ_Hao's blog

By GVZ_Hao, history, 5 years ago, In English

In this problem: 1364E - X-OR ,the discription said "Exit immediately after receiving −1 and you will see wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream." .

And in this submission 83742870, I followed this instruction by using if(val==-1)return 0;(in line 53,67,68,84), and I got a "wrong answer" . But after that ,I change the sentence from if(val==-1)return 0; to 'if(val1==-1){while(1);return 0;}' , and I got a "Accept" 83742993.

I have no idea what is going on.....

  • Vote: I like it
  • +76
  • Vote: I do not like it

»
5 years ago, # |
  Vote: I like it +24 Vote: I do not like it

Your solution is non-determenistic, verdicts can change without any changes in the code.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    That is true. But i submited the same code 5 times before changing that sentences, and 5 times after changing that sentences. All my submission before changing get"wrong answer", and all my submission after changing get "accept" . You can see my submission for more detail QWQ

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Yes, that is strange. But with fixed randseed both variants fail the same test (one by WA and one by TL).

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +106 Vote: I do not like it

      OK, I give up :)

      I have an idea though: As far as I know, Codeforces reruns a submit several times if it gets TL, so maybe this technic significantly increases the probability of success by abusing Codeforces generousity.

      Let's say that probability to fail a test is $$$p=10^{-3}$$$. It is not good since we have around 100 tests. But if on fail solution gets TL, and then rerun two times, and to pass a test you only have to do it once, then probability to fail a test is $$$p^3=10^{-9}$$$ which is much better.

»
5 years ago, # |
  Vote: I like it +14 Vote: I do not like it

I wrote a blog about this exact thing just now. In my blog I came to the same conclusion that Um_nik wrote in his comment.