M.A.H.M.O.O.D's blog

By M.A.H.M.O.O.D, history, 7 years ago, In English

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.

:)

  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +10 Vote: I do not like it

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.