Zorgian Amusement Park (IOI Training Camp 2010: India)
Problem in short:
You are given a rooted tree where each node has a value associated with it. Count the number of pairs of nodes a and b such that a is an ancestor of b and the value of all nodes between a and b is smaller than the value of nodes a and b. N ≤ 200000.
Check out the discussion responses for solution one hint at a time!