正文
增加 3 行删除 3 行
23 行未改动2425262728293031328 行未改动414243444546474849505158 行未改动23 行未改动其中 5 号点以经从它的儿子里转移好了,巡游路线是 $5 \sim 7$,绿色的叉是这么选所设的路障。现在点 2 需要从点 5 转移过来,蓝色的叉为这么选所设的路障,注意到因为我们现在巡游路线是由点 2 走向点 5,所以 2 到 5 这条边不应再设路障,所以是 $dp_{5,0} - 1$。这里还有 2 号点产生的新贡献,即 $to_{2} - 1$,是除了 2 到 5 这条边之外的其它边 2 号点走出去的其他边。所以总的路障数是 $dp_{5, 0} - 1 + to_{2} - 1 = dp_{5,0} + to_2 - 2$,就是我们上面的式子。8 行未改动using namespace std;const int maxn = 200010;const int inf = 1e9;const int hs = 131;// 或 1331//unsigned long long//cout << fixed << setprecision(3)//cout << setw(5) <<//continuevector<int> v[maxn];int dp[maxn][2], id[maxn][2], to[maxn];void dfs(int x, int f){58 行未改动23 行未改动2425262728293031328 行未改动414243444546474849505158 行未改动23 行未改动其中 5 号点以经从它的儿子里转移好了,巡游路线是 $5 \sim 7$,绿色的叉是这么选所设的路障。现在点 2 需要从点 5 转移过来,蓝色的叉为这么选所设的路障,注意到因为我们现在巡游路线是由点 2 走向点 5,所以 2 到 5 这条边不应再设路障,所以是 $dp_{5,0} - 1$。这里还有 2 号点产生的新贡献,即 $to_{2} - 1$,是除了 2 到 5 这条边之外的其它边 2 号点走出去的其他边。所以总的路障数是 $dp_{5, 0} - 1 + to_{2} - 1 = dp_{5,0} + to_2 - 2$,就是我们上面的式子。8 行未改动using namespace std;const int maxn = 200010;const int inf = 1e9;const int hs = 131;// 或 1331//unsigned long long//cout << fixed << setprecision(3)//cout << setw(5) <<//continuevector<int> v[maxn];int dp[maxn][2], id[maxn][2], to[maxn];void dfs(int x, int f){58 行未改动