Polyn0mial's blog

By Polyn0mial, history, 3 years ago, In English

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.

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

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

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.

»
3 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

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.

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

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

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

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

    My stress test command