XOR queries

i used persistent segment tree to solve this problem. my code complexity is M*lgn. but it still gets tle in the last test case :cry: if anyone can point to any optimization it would be very helpful :slight_smile:
http://www.codechef.com/viewsolution/5888456

You can make it without using pointers, which are very slow.Once you need a new node in your trie(I see they are persistent segment trie in your solution), you just make something like nr ++, and nr is going to be the new node, or if you want, A[nr], where A is a structure that remebears what you need.

I am unable to open your solution for some reason.

Here is my persistent segment tree solution using pointers with a full AC. :smiley:

Maybe you can figure out a way to optimize your solution from that.

Good luck! :slight_smile: