#include #include "disjoint_set.hpp" #define endl '\n' using namespace std; void print(DisjointSet *ds) { cout << ds->root(0) << " " << ds->size(0) << " " << ds->root(1) << " " << ds->size(1) << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); auto ds = disjoint_set()->with_undo()->init(2); print(ds); ds->merge(0, 1); print(ds); ds->undo(); print(ds); // This disjoint set doesn't build history vector ds = disjoint_set()->init(2); print(ds); ds->merge(0, 1); print(ds); // This is runtime error since this disjoint set doesn't implement undo // ds->undo(); // print(ds); return 0; }