正文
增加 7 行删除 7 行
14 行未改动1516171819202122234 行未改动282930313233343536373839404142434445464748495051525354555614 行未改动14 行未改动const int N = 2E5 + 5;int n, u, v;/*up:pushup the things down:pushdown the things*/vector<LL> G[N], x, y, c;LL h[N], ave, dis[N];void newop(int from, int to, LL val) {//新操作x.push_back(from);4 行未改动dis[u] = h[u] - ave;for (int v: G[u]) {if (v == f) continue;calc(v, u);dis[u] += dis[v];}}void dfs(int u, int f) {//构造运输方案for (int v: G[u]) {//干草>平均值if (v == f) continue;if (dis[v] > 0) {dfs(v, u);newop(v, u, dis[v]);}if (dis[v] == 0) dfs(v, u);}for (int v: G[u]) {//干草<平均值if (v == f) continue;if (dis[v] < 0) {h[v] -= dis[v];newop(u, v, -dis[v]);dfs(v, u);}}}int main(){scanf("%d", &n);14 行未改动14 行未改动1516171819202122234 行未改动282930313233343536373839404142434445464748495051525354555614 行未改动14 行未改动const int N = 2E5 + 5;int n, u, v;/*up:pushup the things down:pushdown the things*/vector<LL> G[N], x, y, c;LL h[N], ave, dis[N];void newop(int from, int to, LL val) {//新操作x.push_back(from);4 行未改动dis[u] = h[u] - ave;for (int v: G[u]) {if (v == f) continue;calc(v, u);dis[u] += dis[v];}}void dfs(int u, int f) {//构造运输方案for (int v: G[u]) {//干草>平均值if (v == f) continue;if (dis[v] > 0) {dfs(v, u);newop(v, u, dis[v]);}if (dis[v] == 0) dfs(v, u);}for (int v: G[u]) {//干草<平均值if (v == f) continue;if (dis[v] < 0) {h[v] -= dis[v];newop(u, v, -dis[v]);dfs(v, u);}}}int main(){scanf("%d", &n);14 行未改动