Блог пользователя Sindy

Автор Sindy, история, 12 месяцев назад, По-английски

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

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
12 месяцев назад, # |
  Проголосовать: нравится +21 Проголосовать: не нравится

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.

  • »
    »
    12 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    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.