树链剖分
算球?
在校学生
展开
-
bzoj 1036: [ZJOI2008]树的统计Count(树链剖分)
参考:http://hzwer.com/2543.html 初学树链剖分,借鉴大佬代码。。。 这应该是树链剖分裸题。。。#include <bits/stdc++.h> using namespace std;const int inf = 0x7fffffff; const int MAXN = 30005; const int MAXM = 60005;struct Edge { i原创 2017-10-03 13:07:14 · 166 阅读 · 0 评论 -
hdu 3966 Aragorn's Story(树链剖分)
kuangbin大佬模板里的,点权的模板。。。#include <bits/stdc++.h> using namespace std;const int MAXN = 50010; struct Edge { int to,next; } edge[MAXN*2]; int head[MAXN],tot; int top[MAXN]; int fa[MAXN]; int dep[MAXN]原创 2017-10-03 14:43:21 · 192 阅读 · 0 评论 -
spoj 375 QTREE - Query on a tree(树链剖分,边权)
边权的树链剖分,把边权都推到下边的点上,就是点权了,然后,根节点没有权值。 还是kuangbin大佬的模板。。。。#include <bits/stdc++.h> //每条变两个点,把每条边的权值放到深度较深的那个点上,根节点无权值,就是方个最小值 const int MAXN = 10010; struct Edge { int to,next; } edge[MAXN*2]; int原创 2017-10-03 16:28:58 · 252 阅读 · 0 评论 -
LightOJ 1348 Aladdin and the Return Journey(树链剖分)
树剖裸题,套kuangbin大佬的模板#include <bits/stdc++.h> using namespace std;const int MAXN = 30010; struct Edge { int to,next; } edge[MAXN*2]; int head[MAXN],tot; int top[MAXN]; int fa[MAXN]; int deep[MAXN]; i原创 2017-11-06 23:21:35 · 271 阅读 · 0 评论 -
poj 2763 Housewife Wind(树链剖分,边权)
树剖裸题,wa了好久,才发现线段树传错参数了。。。。#include <stdio.h> #include <string.h> #include <algorithm> using namespace std;const int MAXN = 1e5+10;struct Edge { int to,next; } edge[MAXN*2]; int head[MAXN],tot; int原创 2017-11-07 19:53:44 · 249 阅读 · 0 评论 -
FZU 2082 过路费(树链剖分,边权)
树剖裸题#include <stdio.h> #include <string.h> #include <algorithm> using namespace std;const int MAXN = 5e4+10;struct Edge { int to,next; } edge[MAXN*2]; int head[MAXN],tot; int top[MAXN]; int fa[MAXN原创 2017-11-07 20:10:05 · 249 阅读 · 0 评论 -
poj 3237 Tree(树链剖分)
wa了半天。。懒惰标记那里要用异或来修改,wa的时候突然想到,万一两次反转相同的区间,反转就取消了,然而我的懒惰标记那里一直col[rt]=1,这样反转就没有取消。。。#include <stdio.h> #include <string.h> #include <algorithm> using namespace std;const int MAXN = 1e5+10; const int IN原创 2017-11-07 23:12:13 · 214 阅读 · 0 评论