complexity analysis help

Revision en4, by Uzumaki_Narutoo, 2020-05-08 20:28:52

Hello every one ,wish you are doing great .... can any one explain how does this code doesn't got TLE ? https://codeforces.com/contest/246/submission/79394388

My idea is:

1-I'm storing all nodes in subtree of u at depth x using dfs time.

2- In every query first I check if I've encountered a query asking about the same nodes then I print answer as I save the ans of every query else then I iterate over all strings at depth d[i] + x at subtree of u and find number of distinct strings using set.

thanks in advance

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Uzumaki_Narutoo 2020-05-08 20:28:52 345
en3 English Uzumaki_Narutoo 2020-05-08 20:20:24 305
en2 English Uzumaki_Narutoo 2020-05-08 19:24:34 6 Tiny change: 'ng great\ncan any on' -> 'ng great\n.... can any on'
en1 English Uzumaki_Narutoo 2020-05-08 19:23:33 199 Initial revision (published)