https://www.codechef.com/APRIL19A/problems/XORMIN

In this problem , why we are using persistent segment tree, can’t we just find maximum xor over the tree using trie for each query?

https://www.codechef.com/APRIL19A/problems/XORMIN

In this problem , why we are using persistent segment tree, can’t we just find maximum xor over the tree using trie for each query?

Consider a={1,2,3,4,5,6,7}. k=3.

4^3 is 7.

Maximum no is 7 in array. 7^3 is 4.

Do you mean that there is an given array {1,2,3,4,5,6,7}.And there are two queries and for both of the queries k=3 . From the first query ans is 7(4^3). Then for the second query , we should look for the maximum xor with the k value = (7(answer of previous query)^ (k of this query)).