(因为一个点的时间增加,它的子树内所有的点的时间也都会增加) merge(pos, ff); return; } int main() { while (1) { n = read(), rt = read(); f[rt] = 0; memset(vis, 0, sizeof(vis)); if ((!n) && (!rt)) break; for (int i = 1; i <= n; i ++ ) a[i] = read(...
(eslint@8.20.0) - eslint-visitor-keys: 3.4.1 - espree: 9.6.0 - esquery: 1.5.0 - esutils: 2.0.3 - fast-deep-equal: 3.1.3 - file-entry-cache: 6.0.1 - functional-red-black-tree: 1.0.1 - glob-parent: 6.0.2 - globals: 13.20.0 - ignore: 5.2.4 - import-fresh: 3.3.0 -...
P2619[国家集训队]Tree I P2620虫洞 P2622关灯问题II P2623物品选取 P2624[HNOI2008]明明的烦恼 P2625豪华游轮 P2626斐波那契数列(升级版) P2627[USACO11OPEN]Mowing the Lawn G P2628冒险岛 P2629好消息,坏消息 P2630图像变换 P2631Barcodes P2632Explorer P2633Count on a tree P2634[国家集训队]聪聪可可...
It is deep and narrow, with extremely strong mysterious color. It consists of three parts: the Luogu Valley, Golden-Peak-Green-Screen Mountain(Jinding Cuiping Mountain)and the Fuhe Mountain. The main landscape includes highland pastures, valentine’s dam,”“mountain girl”, “mother tree”, ...
有两个贪心:1.自底向上dfs,能删就删,这样显然是正确的,因为它最多只会造成它父亲不能删除;2.对于一个节点,优先删除其代价($c[i]+son[i]$)最大的i删除,一定最优,证明略 1 #include<bits/stdc++.h> 2 using namespace std; 3
}/***///树状数组 维护区间和 不解释structBittree{intval[N];inlineintlowbit(intx){returnx&(-x);}inlineintask(RRintpos){intres =0;for(RRinti = pos; i; i -=lowbit(i)) res += val[i];returnres; }inlinevoidchenge(RRintpos, RRintv){for(RRinti = pos; i <=...
2020.5.18 通过【模板】Link Cut Tree (动态树) 初步开始学习LCT2020.5.19 练习练习LCT2020.5.22 从新学莫队(做PPT2020.5.25 通过 500 祭!2020.7.26 初中毕业初中毕业,三年の忆2020.8.18 NOI网络同步赛打铁2020.8.23 15岁了,生日快乐呀!2020.8.31 高一了!
}structVirtual_Tree{inttot,tail;intnow[maxn+8],pre[maxn*2+8],son[maxn*2+8],val[maxn*2+8];intcolor[maxn+8],st[maxn+8],siz[maxn+8]; ll f[maxn+8];voidclear(){for(inti=1;i<=m;i++) color[a[i]]=0;while(tail) now[st[tail--]]=0; ...
tree[rt] = tree[lst] +1;if(l == r)return;intmid = (l + r) >>1;if(pos <= mid)update(ls[rt],ls[lst],l,mid,pos);elseupdate(rs[rt],rs[lst],mid +1,r,pos); }intquery(intL,intR,intl,intr,intk){intz = tree[ls[R]] - tree[ls[L]];if(l == r)returnl;intmid =...
ans +=Rank(tree[pos],x); pos -= pos & -pos; }returnans; }inthave_ad[N];intans[N];intmain(){intn =read();K =read();for(inti =1;i <= n;++i) e[i].a =read(),e[i].b =read(),e[i].c =read();sort(e +1,e + n +1);for(inti =1;i <= n;++i) {if(!ha...