dmkz's blog

By dmkz, history, 6 years ago, translation, In English

I found two C# solutions: with multithreadingAccepted and without multithreadingTLE. The author of the solution uses Parallel.For in the functionMultiplyMatrixPow, due to which it achieves success. Question: how many cores can we load on codeforces servers when testing our solution?

UPD: In first program author takes remainder from integer division 3 times, in second program just 1 times. So, this is not multithreading hack.

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

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

Look at mike's comment: blog.

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Thanks, it turns out that additional cores are not used to run the program.

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

    But why use of the parallel for speed up the solution? Are there any optimizations in comparison with the usual cycle for?

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

As far I know, you'll never decrease the running time on all adequate e-judges via additional threads, since they're single-cored. Your case is probably false-positive, I mean when I was writing solutions on C#, it could give different execution time on the server, and your code may give a result somewhere in an interval [2000-x, 2000+x] of milliseconds, almost randomly.