刚刚发现自己之前写了假的淀粉质...
void Divid(int x) {
vis[x] = true;
// ...略
for (int i = head[x]; i; i = nxt[i])
if (!vis[to[i]]) {
S = siz[to[i]];
msrt = inf;
rt = 0;
getRoot(to[i], x);
Divid(to[i]);
}
}
(注意倒数第三行)
刚刚改成了
void Divid(int x) {
vis[x] = true;
// ... 略
for (int i = head[x]; i; i = nxt[i])
if (!vis[to[i]]) {
S = siz[to[i]];
msrt = inf;
rt = 0;
getRoot(to[i], x);
Divid(rt);
}
}
两个版本的总用时竟然只差了200ms...