ifsmirnov's blog

By ifsmirnov, history, 8 years ago, In English

I'm now participating in my first TC Marathon Match. I decided to run my solution in an infinite loop and stop when TL is almost reached. But it turned out that %%clock()%% function (C++) doesn't return correct time in the system. I printed total time elapsed after each iteration, On some testcases the last entry printed was 210 ms, however, the solution got a TLE verdict (with 10 seconds time limit!). On others it managed to finish on time, but the time printed by tester was significantly larger than what my program printed to the stderr.

Is it possible to do time-based pruning on TC marathons? Which functions should I use for it? I've heard about some clocks from std::chrono, but a limit of one test submission per hour isn't really convenient to test it all.

Oh. And as you're already here, I've got one more question. Where can I find information about how often I can make a judged submission? I googled a bit but found contradictory information (72 hours, 4 hours, some else...) In the ongoing match (TCO Marathon R3) I could make several submissions in about a half an hour, and the next day I had to wait for an hour until the next submission.

I use a web form for submitting, if it matters.

Thank you for helping me climbing the learning curve :)

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

»
8 years ago, # |
  Vote: I like it +18 Vote: I do not like it

There is a thread on the previous round's forums about measuring time. That may help.

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

    Oomph. It's nice to know that I'm not the only one facing the problem, but the solutions themselves aren't that nice. Thanks anyway.

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

      I actually use gettimeofday function to measure time (since clock gives wrong values). Moreover, you shouldn't call this function frequently, since all syscalls are extremely slow in Topcoder. Also, you can try to test it on examples, writing something (like number of operations or iterations of your solution) to stderr. If your solution makes significantly less operations on server that locally that you are doing something wrong with time measuring.

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

        Yeah, I have already experimented with gettimeofday. In this problem it works as expected for me and gives no significant slowdown as I call it only several hundred times. Example testing really helped me to figure out what's going on with time, you're right, it's a very useful option.