BZOJ3237 [Ahoi2013]连通图
CDQ重构图。听上去比CDQ还高档的样子。 就是每层重新标号,把没有询问到的边拿来跑并查集。 最初是分开考虑然后可修复的并查集就T傻了。 #include <cstdio> #include <cstring> #include <cctype> #include <set> #include <algorithm> using namespace std; int _d_; #define readInt(_x_) { \ int& _s_ = _x_; \ while (!isdigit(_d_ = getchar())); \ _s_ = 0; \ while ((_s_ = _s_ * 10 + _d_ - 48), isdigit(_d_ = getchar())); \ } const int maxn = 100009; const int maxm = 200009; const int maxl = 19; struct edge { int a, b, i; }; struct dset { int r[maxn], hp[maxn * 5], hv[maxn * 5], cnt;...