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

Автор dx24816, история, 6 лет назад, По-английски

Hello,

I tried to do QTREE5 (https://www.spoj.com/problems/QTREE5/), but I keep getting WA on test case 5. I'm using Centroid Decomposition, and I'm pretty sure it's correct because I tested it on Codeforces 342E and got AC. That means the error is probably in the closest function, the toggle function, getDist function, or something in the main function. Can somebody point out my error? Thanks!

Code: https://ideone.com/gZ85l8

-dx24816

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

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

Replace (*(cdist[v].rbegin())).first with (*(cdist[v].begin())).first because here we want minimum distance to the node.

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

Is it necessary to keep pair in multiset? I am trying the same way(without pair), still WA. Code: https://ideone.com/PpbbXc Could someone take a look?

Edit: AC using pair, what am i missing? shouldn't it work without information of which node caused which value?

Edit: multiset.erase(multiset.find(value)) works.