正文
增加 1 行删除 1 行
63 行未改动64656667686970717226 行未改动63 行未改动typedef math::mint<mod> MI;int n, k, x, y, vs[N]; MI rs, f[N], fac[N], inv[N]; vector<pii> G[N];void dfs(int x, int fa) {MI co = inv[SZ(G[x]) - 1], s = 0, w = 0; // co 是 x 的点权for (auto [y, i] : G[x]) {if (y == fa) continue;dfs(y, x), w = (vs[i] ? -1 : f[y]);f[x] += w * co, rs += s * w * co, s += w; // 转移 f[x];计算 y->z 的贡献if (vs[i]) rs += -f[y] - 1; // x->y 的贡献26 行未改动63 行未改动64656667686970717226 行未改动63 行未改动typedef math::mint<mod> MI;int n, k, x, y, vs[N]; MI rs, f[N], fac[N], inv[N]; vector<pii> G[N];void dfs(int x, int fa) {MI co = inv[SZ(G[x]) - 1], s = 0, w = 0; // co 是 x 的点权for (auto [y, i] : G[x]) {if (y == fa) continue;dfs(y, x), w = (vs[i] ? -1 : f[y]);f[x] += w * co, rs += s * w * co, s += w; // 转移 f[x];计算 y->z 的贡献if (vs[i]) rs += -f[y] - 1; // x->y 的贡献26 行未改动