Given 2 multisets A and B, |A| = |B|. The task is to find such X that A ^ X = B, where A ^ X means foreach element of A xor it with X; or say that theres no such X. |A| <= 10^5, elements of A, B are decimal number from [0; 10^18].
For example -
If A = {0, 2} and B = {1, 3} then 1 is the answer: A ^ 1 = {1, 3}.
I mean I am looking for algorithm with asymptotic << O(|A|^3 * Log(|A|)) which is straightforward brute force.
Edit: well its seems that intended solution is some 'smart' brute force. FML
There are some things you can do that are not guaranteed to help, so if you get $A,B$ from a malicious source they will not work. For each bit position, count the number of $1$s among the elements of $A$ and $B$. If there are the same number of $0$s and $1$s you have not gained. If there are the same number of $1$s in $A$ and $B$, that bit of $X$ must be zero. If there are the same number of $1$s in $A$ as $0$s in $B$, that bit of $X$ must be $1$. You can see that in the units bit of your example, were there are $0\ 1$s in $A$ and $0\ 0$s in $B$. If there are neither the same number of $0$s nor $1$s in $B$ as $1$s in $A$ you can report failure immediately. Otherwise you (hopefully) have a relatively small number of $X$s to try. You can sort the elements of $A$ into classes by how many of each there are. If the classes do not match $B$, for example there are five numbers that come in three copies in $A$, but only four in $B$, you can report failure immediately. Now do the above or brute force on the smallest class. Again, you should get relatively few candidates for $X$ to try on the other classes.