Nearest vertex in a tree with a smaller value

Revision en2, by dododo89, 2019-11-15 23:18:02

You are given a tree of $$$N<=10^6$$$ vertices. Each vertex of the tree contains a number $$$a[i]<=10^9$$$.You are given $$$M<=10^6$$$ queries: "Find the distance to nearest vertex to the vertex $$$V$$$, with the value less than $$$X<=10^9$$$?"

How this problem can be solved?

Tags #tree, #algorithms

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English dododo89 2019-11-15 23:18:02 4 Tiny change: 'he vertex u, with the' -> 'he vertex $V$, with the'
en1 English dododo89 2019-11-15 23:16:52 308 Initial revision (published)