70pts:你 n,m 写反了捏。
数据是否过水:我并查集 用的路径压缩 过了
具体大概是这么个东西
int find3(int x) {
if(x == f1[x]) return x;
else {
int t = find3(f1[x]);
roll.push_back(mkp(x, f1[x]));
return f1[x] = t;
}
}
void merge3(int x, int y) {
x = find3(x); y = find3(y);
if(x < y) swap(x, y);
if(x != y) roll.push_back(mkp(x, f1[x])), f1[x] = y;
}
while(roll.size()) {
PII nw = roll.back(); roll.pop_back();
f1[nw.fi] = nw.se;
}