正文
增加 8 行删除 8 行
39 行未改动40414243444546474849505152535455565758596061625 行未改动68697071727374757627 行未改动10410510610710810911011111211311428 行未改动39 行未改动inline void add(int x, int y, int z) {ne[++tot] = h[x], to[h[x] = tot] = y, w[tot] = z;}int Siz, siz[N], vis[N], las[N], lim, ed;inline void adde(int x, int y, int z) {add(x, y, z), add(y, x, z);// write(x, ' '), write(y, ' '), write(z);}void get(int x, int fa) {siz[x] = 1;for (int i = h[x], y; i; i = ne[i]) {if ((y = to[i]) == fa || vis[i]) continue;get(y, x), siz[x] += siz[y];int tp = max(siz[y], Siz - siz[y]);if (tp < lim) lim = tp, ed = i;}}void dfs(int x, int fa, ll Dis, int ty) {if (x <= n) {++nodecnt, !rt[x] && (rt[x] = nodecnt);if (ls(las[x]) == -1) ls(las[x]) = nodecnt;5 行未改动for (int i = h[x], y; i; i = ne[i])if ((y = to[i]) != fa && !vis[i])dfs(y, x, Dis + w[i], ty);}void conquer(int x, int S) {if (S <= 1) return;Siz = lim = S, get(x, 0), vis[ed] = vis[ed ^ 1] = 1;int tx = to[ed], ty = to[ed ^ 1];27 行未改动return rt;}ll query(int nw, int p1, int p2) {if (sl(nw) > 0)return query(ls(nw), ls(p1), ls(p2)) + vr(p2) - vr(p1) + (sr(p2) - sr(p1)) * vl(nw);if (sr(nw) > 0)return query(rs(nw), rs(p1), rs(p2)) + vl(p2) - vl(p1) + (sl(p2) - sl(p1)) * vr(nw);return 0;}28 行未改动39 行未改动40414243444546474849505152535455565758596061625 行未改动68697071727374757627 行未改动10410510610710810911011111211311428 行未改动39 行未改动inline void add(int x, int y, int z) {ne[++tot] = h[x], to[h[x] = tot] = y, w[tot] = z;}int Siz, siz[N], vis[N], las[N], lim, ed;inline void adde(int x, int y, int z) {add(x, y, z), add(y, x, z);// write(x, ' '), write(y, ' '), write(z);}void get(int x, int fa) {siz[x] = 1;for (int i = h[x], y; i; i = ne[i]) {if ((y = to[i]) == fa || vis[i]) continue;get(y, x), siz[x] += siz[y];int tp = max(siz[y], Siz - siz[y]);if (tp < lim) lim = tp, ed = i;}}void dfs(int x, int fa, ll Dis, int ty) {if (x <= n) {++nodecnt, !rt[x] && (rt[x] = nodecnt);if (ls(las[x]) == -1) ls(las[x]) = nodecnt;5 行未改动for (int i = h[x], y; i; i = ne[i])if ((y = to[i]) != fa && !vis[i])dfs(y, x, Dis + w[i], ty);}void conquer(int x, int S) {if (S <= 1) return;Siz = lim = S, get(x, 0), vis[ed] = vis[ed ^ 1] = 1;int tx = to[ed], ty = to[ed ^ 1];27 行未改动return rt;}ll query(int nw, int p1, int p2) {if (sl(nw) > 0)return query(ls(nw), ls(p1), ls(p2)) + vr(p2) - vr(p1) + (sr(p2) - sr(p1)) * vl(nw);if (sr(nw) > 0)return query(rs(nw), rs(p1), rs(p2)) + vl(p2) - vl(p1) + (sl(p2) - sl(p1)) * vr(nw);return 0;}28 行未改动