![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LCA/树链剖分
等我学会后缀自动机
侠影之谜
展开
-
HDU 5614 Baby Ming and Matrix tree (树链剖分+线段树区间修改)
#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,m...原创 2020-04-17 10:43:37 · 146 阅读 · 0 评论 -
CodeForces 1260F Colored Tree (树剖+计数思维+一点点DP思维)
#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,m...原创 2020-04-10 11:35:25 · 172 阅读 · 0 评论 -
HDU 4912 Paths on the tree (树链剖分+线段树+DP)
#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,m...原创 2020-03-31 19:54:28 · 189 阅读 · 0 评论 -
HDU 5029 Relief grain (树链剖分+权值线段树思想)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-03-26 18:10:52 · 187 阅读 · 0 评论 -
HDU 5296 Annoying problem (树剖求LCA+链的距离)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-03-23 19:32:29 · 115 阅读 · 0 评论 -
HDU 5293 Tree chain problem (树链剖分+LCA+树形DP)
#include<bits/stdc++.h>using namespace std;#pragma comment(linker, "/STACK:1024000000,1024000000") #define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#de...原创 2020-03-21 11:34:28 · 159 阅读 · 0 评论 -
HDU 5452 Minimum Cut (树链剖分)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-03-17 15:17:23 · 126 阅读 · 1 评论 -
P4211 [LNOI2014]LCA (树链剖分+思维)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-03-09 00:38:46 · 130 阅读 · 0 评论 -
CodeForces 1254D Tree Queries (树链剖分技巧+树状数组)
#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,m...原创 2020-02-19 12:11:01 · 306 阅读 · 0 评论 -
HDU 6393 Traffic Network in Numazu (树链剖分+线段树)
#include<bits/stdc++.h>using namespace std;#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,mid,rt<<1#define rson...原创 2020-02-18 16:38:35 · 128 阅读 · 0 评论 -
Gym 102012G Rikka with Intersections of Paths (树上差分+LCA)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-02-17 22:19:22 · 430 阅读 · 0 评论 -
Gym 101142G Gangsters in Central City (动态倍增LCA+DFS序性质)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-02-16 22:19:30 · 181 阅读 · 0 评论 -
poj 2763 Housewife Wind (树链剖分)
#include<iostream>#include<cstdio>#include<vector>#include<cstring>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2020-02-14 17:24:56 · 123 阅读 · 0 评论 -
HDU 6162 Ch’s gift (树链剖分+线段树维护)
#include<bits/stdc++.h>using namespace std;#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define lson l,mid,rt<<1#define rson...原创 2020-02-14 10:58:17 · 119 阅读 · 0 评论 -
HDU 5893 List wants to travel (树链剖分+线段树维护+踩坑)
#include<bits/stdc++.h>using namespace std;#define debug cout<<"YES\n";#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll long long#define lrt int l,int r,int rt#define ...原创 2020-02-14 10:51:44 · 173 阅读 · 0 评论 -
HDU 3966 Aragorn's Story (树链剖分第一题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3966#include<bits/stdc++.h>using namespace std;const int maxn =1e5+5;/*题目大意:就是在一颗树上维护,两点间路径的权重修改,查询单点权值.对于树上路径的维护和修改,树链剖分的话最重要的还是一种分块的思...原创 2018-10-05 00:13:47 · 119 阅读 · 0 评论 -
HDU 2586 How far away ? (Tarjan离线算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define read(x...原创 2018-10-13 09:24:06 · 86 阅读 · 0 评论 -
POJ 1330 Nearest Common Ancestors (LCA模板题)
题目链接:http://poj.org/problem?id=1330#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)&l...原创 2018-09-30 14:30:19 · 184 阅读 · 0 评论 -
HYSBZ 2243 染色 (树链剖分+线段树)*
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2243///#include<bits/stdc++.h>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define de...原创 2018-11-16 16:32:20 · 204 阅读 · 0 评论 -
HDU 6203 ping ping ping (在线倍增lca+DFS序+树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6203#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2018-11-17 15:50:52 · 199 阅读 · 0 评论 -
HDU 5266 pog loves szh III (线段树+lca水题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5266#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2018-11-17 16:44:24 · 159 阅读 · 0 评论 -
HDU 6430 Problem E. TeaTree (动态倍增LCA+DFS序性质+gcd计数技巧)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6430#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define ll uns...原创 2018-11-18 11:19:49 · 132 阅读 · 0 评论 -
Codeforces Round #537 (Div. 2) E. Tree(DP+树状数组统计+LCA)*
题目链接:http://codeforces.com/contest/1111/problem/E题目大意:给定一棵树,和若干个询问,k,m,r和k个数,问把这k个点分成至多m组且每组中的点集没有父节点与子节点的关系,其方案数有多少种。题目分析: 这道题我是看了别人的思路才懂的,果然还是自己太弱了呀。。。先简化问题,如果根是固定的如何考虑,那么观察到m的数据范围去...原创 2019-02-24 18:28:58 · 161 阅读 · 0 评论 -
南昌邀请赛网络赛 Distance on the tree (主席树+动态倍增LCA)
题目链接:https://nanti.jisuanke.com/t/38229考研ing,题解比较随意题目大意给定一棵树,有边权,每次查询问u,v路径上权值不大于k的个数是多少.题目分析主席树,每个点记录是所有祖先节点记录的前缀和,那么对于主席树来讲前后关系就明显了.再套个动态倍增LCA,就可以做了.详见代码#include<bits/stdc++...原创 2019-05-10 21:04:12 · 164 阅读 · 0 评论 -
HDU 2586 How far away ? (LCA_Tarjan)
How far away ?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23711 Accepted Submission(s): 9434 Problem DescriptionThere are n house...原创 2018-08-30 14:04:28 · 151 阅读 · 0 评论