Is it possible to implement XOR Basis with deletion whether online or offline?
If it's possible can someone share an implementation?
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | Radewoosh | 3415 |
| 8 | Um_nik | 3376 |
| 9 | maroonrk | 3361 |
| 10 | XVIII | 3345 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 133 |
Is it possible to implement XOR Basis with deletion whether online or offline?
If it's possible can someone share an implementation?
| Name |
|---|



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.
You can find it here
Wow very beautiful, i thought it is only possible offline to implement in n log n log a_i.
Thanks!
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
Thanks!