版本比较
P6227 [BalticOI 2019 Day1] 山谷
正文
增加 4 行删除 4 行
68 行未改动69707172737473747576777869 行未改动14814915015115215315215315415515615714 行未改动68 行未改动typedef long long ll;const int Num = 1e5 + 5;int n, s, q, e;int go[Num][20], dep[Num], u[Num], v[Num], shop_num[Num];// shop_num[i] 表示i及i的子树内有多少商店 ll c[Num], near_shop[Num], f[Num][20], p[Num]; //这几个都要开long long!!! // shop_num[i] 表示i及i的子树内有多少商店ll c[Num], near_shop[Num], f[Num][20], p[Num]; //这几个都要开long long!!!//!!!只用统计子树内的最近商店,子树外的以后会统计到或根本用不到bool mark[Num];struct edge { int to;69 行未改动 dfs_shop(e, e); //!!!只用统计子树内的最近商店,子树外的以后会统计到 for (int t = 1; t <= 18; t++) for (int i = 1; i <= n; i++) go[i][t] = go[go[i][t - 1]][t - 1]; for (int i = 1; i <= n; i++)p[i] = near_shop[i] - c[i]; //p临时存一下,因为f[i][t]需要表示走2^t步 for (int i = 1; i <= n; i++)p[i] = near_shop[i] - c[i]; //p临时存一下,因为f[i][t]需要表示走2^t步 for (int i = 1; i <= n; i++)f[i][0] = min(p[i],p[go[i][0]]); //如果i为商店,f[i][0]不需要置为0!!! for (int t = 1; t <= 18; t++) for (int i = 1; i <= n; i++)14 行未改动