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

Автор Polyn0mial, история, 2 года назад, По-английски

I was solving this Problem Link and encountered a bug. I'm getting WA on test 10, but I run stress test locally on my PC and didn't found any counter test cases. Please take a look on my code.

Approach that I used to solve this problem

Here are my code.

Test Case Generator
Brute force solution
My submission

EDIT: SOLVED. Stupid mistake in binary lifting function.

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

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Notice that if it seems you get WA on the last test in SPOJ, you may get WA on any test before, not just test case 10.

»
2 года назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

I found your mistake:

In lambda auto lift = [&](int u, int step) -> int(line 59), you should replace r <<= 1; for r++;, as dp[i][j] means the $$$2^j$$$ -th father of node $$$i$$$.

AC submission 29145844.

  • »
    »
    2 года назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    Thanks. That's a stupid mistake made by me. It worked.

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

    It is strange that stress test didn't find this bug.

    My stress test command