Блог пользователя radoslav11

Автор radoslav11, история, 10 лет назад, По-английски

Hello!

I was solving problem Minxor from second day of RMI 2014. In short the problem is:

You have 3 types of queries.

1 x -> inserts x into the set
2 x -> deletes x from the set
3 -> asks for the smallest xor of any two numbers in the set

I solved the problem offline using a trie + divide and conquer. My solution is similar to link. Again in short: compressing all updates as "number x appears from time I to time J". Here is the code. The complexity is O(M * log(M) * 32);

So my question is:

Is there a solution which runs faster than that or/is online. Thanks in advance :)

  • Проголосовать: нравится
  • +9
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Yes, there's a simpler, online, O(log M) per query solution. Notice that if a < b < c, the minimum xor pair is never (a, c).