Блог пользователя M.A.H.M.O.O.D

Автор M.A.H.M.O.O.D, история, 7 лет назад, По-английски

Good day CF community.

Today I tried to challenge myself and solve a hard problem and I did...kinda.

Right now I'm stuck in test 8 I have no idea what's wrong with my solution could somebody please help me out ???

Here is my code 22656856 and the problem 588E - Duff в армии.

My idea is to find the IDs from node u to node 1 and from node v to node 1 and from LCA(u,v) to node 1 and then my answer will be (IDs(u) + IDs(v) — IDs(LCA(u,v))) I'm not sure if the idea is wrong or the implementation.

I'll be very grateful for any kind of help.

Thank you for reading.

:)

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

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

I don't think what you are doing is correct because you might end up with an empty set if IDs in LCA(u,v) end up cancelling everything in u and v. It is too greedy to only keep the 10 best at each node.