Sindy's blog

By Sindy, history, 4 months ago, In English

Just curious to know if anyone has tried to write concurrent solutions in programming contests ?

  • Vote: I like it
  • 0
  • Vote: I do not like it

4 months ago, # |
  Vote: I like it +21 Vote: I do not like it

As far as I know, using concurrency features on codeforces is useless. You can try to print std::thread::hardware_concurrency() and you'll find codeforces use only one core to judge one program. You can try the following program in custom test:

concurrency test program

And even you can use concurrency on some contest, it only helps you with constant optimization, not time complexity, which is more important in competitive programming.

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

    Actually this program has an undefined behavior.

    In function bar():

    for (unsigned int i = 0; i < N; i++) {
        ans += std::log(i);

    std::log(0) is undefined. So this program prints different results in different environments. This confused me a lot.

    Anyway, this doesn't matter.