ENG  RUSTimus 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

AC in 0.249 and 8668 KB (RMQ for lca)
Posted by sak3t 29 May 2017 15:39
used RMQ using segment tree to find lca in log(n)
total time complexity O(n+q*(lgn)) = O(q*lgn)
Re: AC in 0.249 and 8668 KB (RMQ for lca)
Posted by Mahilewets 15 Jun 2017 22:06
Almost the same numbers (0.268, 11500) for table for 2^i -th ancestor.