Please read the new rule regarding the restriction on the use of AI tools. ×

Yet Another Tree Problem

Revision en1, by Tyler__Durden, 2018-11-28 00:59:34

I am stuck on this following problem:

Given an undirected tree of n nodes and q queries of type (u,d), for each query you need find the number of simple paths starting from node u and having distance <=d.

Constraints:

1<=n,q,u,d<=100000

Any suggestion will be highly appreciated. Thanks.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Tyler__Durden 2018-11-28 01:02:04 5 Tiny change: 'nd having distance ' -> 'nd having edge distance '
en1 English Tyler__Durden 2018-11-28 00:59:34 327 Initial revision (published)