dalex's blog

By dalex, 12 years ago, translation, In English

Hello.

I and I_love_natalia just discovered a strange problem which came to me when I generated antiquicksort-test. I even got an unsuccessfull hack on today's round because of it. It was surprising to me that my victim's program had worked so fast on the antiquicksort test. But at the end of the contest I changed the size of array in the generator from 100000 to 99987, and the hack became successful!

I don't know why it happens. This is the test case:

  1. Run test generator from http://pastebin.com/99RwHR6w in Codeforces Custom Test interface.

  2. Server will output you something like Sorting ended in 1953ms

  3. Add two empty lines to the end of the code and run it again.

  4. Result is: Sorting ended in 0ms.

You can add and delete spaces and empty lines from random places of the code and the results will be different: array can be sorted in zero time or in about 2 seconds.

I uploaded a video with this issue, you can download and watch it: link (be careful, being unzipped, it is about 600 MB)

So what is it? A bug of Java virtual machine? Or Codeforces server tries to protect contestants from antiquicksort?

UPDATE: As it turned out, some Codeforces servers have Java 7. Java 7 has other implementation of sort, so that's why some runs on antiquicksort tests are fast. It is not good because I submit my solution under Java 6 but it can run under Java 7 instead. Please note it till admins fix that issue.

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

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

The victim would be me :D

»
12 years ago, # |
  Vote: I like it 0 Vote: I do not like it

May I ask in which version of Java is the problem actual? Java 7 or Java 6? Thanks

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

    There's no problem any more. The only problem was "when you submit your solution under Java 6 it can run under Java 7 instead".