版本比较
题解 【LOJ574】黄金矿工
正文
增加 5 行删除 5 行
121 行未改动全部展开1221231241251261261271281291302 行未改动1331341351361371371381391401412 行未改动144145146147148148149150151152153154155156157158157158159160161162109 行未改动全部展开121 行未改动全部展开 if (mid >= l) res = query(x<<1,l,r,fl); if (mid < r) res = max(res,query(x<<1|1,l,r,fl)); return res;}int queryr(int x,int l,int r) {// 区间从右往左第一个 <0 的位置 因为前面先减了1 int queryr(int x,int l,int r) {// 区间从右往左第一个 <0 的位置 因为前面先减了1 if (l > r || t[x].mn >= 0) return -1; if (t[x].l == t[x].r) return t[x].l; int mid = t[x].l + t[x].r >> 1; pushdown(x);2 行未改动 if (t != -1) return t; } return mid >= l ? queryr(x<<1,l,r) : -1;}int queryl(int x,int l,int r) {// 区间从左往右第一个 <=0 的位置 int queryl(int x,int l,int r) {// 区间从左往右第一个 <=0 的位置 if (l > r) return -1; if (t[x].l == t[x].r) return t[x].mn > 0 ? -1 : t[x].l; int mid = t[x].l + t[x].r >> 1; pushdown(x);2 行未改动 if (t != -1) return t; } return mid < r ? queryl(x<<1|1,l,r) : -1;}int get1(int x) {//find a gold int get1(int x) {//find a gold while (x) { int t = queryr(1,id[top[x]],id[x]); if (t != -1) return rnk[t]; x = fa[top[x]]; } return 1;}multiset<ll> S[2][N + 10];//0 是矿工 1 是黄金multiset<node> W[N + 10];//矿工轻儿子上来的最大值 node get0(int x) {//重链前缀的最大值 find a miner multiset<node> W[N + 10];//矿工轻儿子上来的最大值node get0(int x) {//重链前缀的最大值 find a miner int tt = queryl(1,id[x],down[x]); return query(1,id[x],tt == -1 ? down[x] : tt - 1,0);}void updf(int x,int v) {109 行未改动全部展开