Alternative solution to standard tree query problem?

Revision en1, by yyyvvvyyy, 2017-03-04 00:50:06

I was solving this problem which seemed like a pretty much standard problem of persistent segment tree but i came across this solution which seems to use some dfs ordering of nodes and i'm unable to figure out what is going on?

Problem: Given a tree (100000 nodes) and a value in each node, and for each query you are given 2 nodes and a value V , you have to find number of nodes whose value is less than V.

solution: https://www.hackerearth.com/challenge/college/programmers-parliament/algorithm/freaky-frequencies/submission/7492012/

This is my first time on codeforces. Thanks in advance

Tags #trees, #dfs, persistent segment tree, hld

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English yyyvvvyyy 2017-03-04 00:50:06 658 Initial revision (published)