ashish11's blog

By ashish11, history, 6 years ago, In English

I wrote a solution to https://www.codechef.com/problems/INVENTRY during the Snackdown pre-elimination. The code received verdict WA, so after contest I downloaded several accepted solutions, and tested against randomly generated test cases of various sizes (20-100). In all these cases the answer outputted is the same, and presumably correct given that their codes were accepted.

Since there are only two possible characters, I think almost every non-trivial pattern should occur in my tests, given that I tested over 1e6 cases. It also doesn't appear to err due to the fact that the judging is being done on codechef servers (I tested it on ideone).

Could there be a reasonable explanation to this? I obviously can't prove this, but it seems that for any normal code, all cases where it can fail should also be reproducible on relatively small cases.

Here is my code, if you need for reference : https://www.codechef.com/viewsolution/21437285

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

»
6 years ago, # |
  Vote: I like it +17 Vote: I do not like it

The answer can possibly exceed the range of a 32-bit integer.

Try the case consisting 99999 characters, with 1 ., 49999 # and 49999 . characters.

Of course the answer is 2499900001 but your code outputs some garbage (it outputs -1795067295 on my machine, but signed overflow is undefined).

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

    Not even sure what to say on this. Thanks for the help.