Help in E.Duff in the army

Revision en1, by M.A.H.M.O.O.D, 2016-12-02 15:30:58

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.

:)

Tags trees, lca, sparse table, help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English M.A.H.M.O.O.D 2016-12-02 15:30:58 627 Initial revision (published)