XORMIN problem

algorithm
tree
trie

#1

The XORMIN problem from April’s Long Challenge.

This is the logic that I implemented:-

  1. Find the euler tour and create the array (ar)
  2. Find starting and ending time of each index(array ‘tme’ of pairs)
  3. Each trie stores its children, minimumVertex and maxStartTime.
  4. trie[i] stores values from 1 upto i in ar.
  5. Create trie[i+1] from trie[i] using persistence
  6. For a query (vertex, k) find the max xor in the trie[ tme[vertex].second ] using the help of maxStartTime.

Is this logic wrong? If not then what could be the possible reason for RE in some test cases?

Here is the code link .

PS: The code is not difficult to understand-it is commented.