ENG
RUS
Timus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board
Discussion of Problem
1471
. Distance in the Tree
hint solution
Posted by
mastercopycode
4 Aug 2021 01:29
you can use Binary Lifting,find lca of u and v
you find distance u with root of tree
the result=dis[a]+dis[b]-2*dis[lca(a,b)]
© 2000–2024
Timus Online Judge Team
. All rights reserved.