Hello everyone! I am trying to solve the following problem:

You are given a DSU (Union Find) data structure, and you need to do the following queries efficiently:

- Go back to time t, and insert a union operation (Union(u, v, t)) at time t.
- Undo the union at time t.
- Given time t, and two nodes u, v check if nodes u and v are in the same connected component at that time.

Any help or offline / online solution would be perfect!

Undoing operations online is quite hard. This is a solution to the online problem without undoing operations: Maintaing mst with onl8ne edge insertions You can use offline deletion trick on the above DS for your general problem. Hope it is still relevent

use a stack its called rollback dsu

this is oonline solution btw

DSU with rollbacks + splitting queries into blocks would work in some sqrt time complexity. You can see APIO 2019 Bridges for some similar solution.