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

Автор Shoeib, история, 4 месяца назад, По-английски

Is it possible to implement XOR Basis with deletion whether online or offline?
If it's possible can someone share an implementation?

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

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится -22 Проголосовать: не нравится

I think operations are idempotent. Because let's say you generate a basis. There are 2^basis size possible.

I guess you can do the same thing as you do on idempotent functions. Like what would you do calculate range and, or. You work on intervals. Same thing you can do here.

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

You can find it here

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

Deletions of specific values can be done offline with divide & conquer over time. Track when each value is “alive” as an interval $$$[l,r]$$$, add it to every segtree node whose segment lies fully inside $$$[l,r]$$$, then DFS the segtree with a rollback xor-basis. The basis at time $$$i$$$ is exactly what you have at the $$$i$$$-th leaf.

If online queries are forced, you can use this method. It runs in around $$$O(B^2)$$$ per op, so its slower than the d&c for sure.

Side Note: Another trick I find useful is “recency bias” over vectors. When inserting, also store a time/position. If a vector with the same leading bit already exists, compare times: if the incoming one is more recent, swap them so the basis keeps the newer vector, and keep inserting the older one; otherwise xor and continue. Definitely useful for span queries over contiguous ranges when you process queries offline.

Some problems to look at:

2116F - Gellyfish and Forget-Me-Not

1100F - Ivan and Burgers

1902F - Trees and XOR Queries Again