
(线段树,树上)启发式合并
C++
等我学会后缀自动机
侠影之谜
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
CodeForces 208E Blood Cousins (启发式合并+倍增)
#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-20 00:12:15 · 213 阅读 · 0 评论 -
CodeForces 246E Blood Cousins Return (树上启发式合并)
#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-18 08:36:07 · 248 阅读 · 0 评论 -
ZOJ 4053 Couleur (启发式合并+主席树)
#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-10 17:31:59 · 265 阅读 · 0 评论 -
CSU 1811 Tree Intersection (树上启发式合并+map)
#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 23:56:00 · 175 阅读 · 0 评论 -
CodeForces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 树上启发式合并+状态压缩
#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-12 21:19:08 · 433 阅读 · 0 评论 -
CodeForces 570D Tree Requests (树上启发式合并)
#include<bits/stdc++.h>using namespace std;#define rep(x,y,z) for(int (x)=(y);(x)<(z);x++)#define mst(x,y) memset(x,y,sizeof(x))#define ll long longconst int maxn=5e5+10;#define pii pa...原创 2020-02-11 23:20:02 · 153 阅读 · 0 评论 -
CodeForces 600E Lomsat gelral 树上启发式合并
#include<bits/stdc++.h>using namespace std;#define rep(x,y,z) for(int (x)=(y);(x)<(z);x++)#define mst(x,y) memset(x,y,sizeof(x))#define ll long longconst int maxn=1e5+10;const int maxk...原创 2020-02-02 23:31:43 · 249 阅读 · 0 评论 -
HYSBZ 1483 梦幻布丁 (启发式合并)
题目链接:https://vjudge.net/problem/134273/origin题目大意中文题目,不过多解释了题目分析启发式合并,据说模拟两个数据结构合并的过程中用容量小的去加入容量大的的话可以把复杂度降低为nlogn.对于这道题,我们维护以颜色为标记的链表,用vector存储各个相同颜色的下标,并且映射关系逻辑要理清楚,因为我们通过启发式合并可能把颜色...原创 2019-03-28 18:58:07 · 192 阅读 · 0 评论 -
Codeforces Round #541 (Div. 2)F. Asya And Kittens(启发式合并+并查集+构造)
题目链接:http://codeforces.com/contest/1131/problem/F题目大意给定n个操作,其意义是把两个线段区间合并成一个,现在要构造一种排列使得这些操作合法。题目分析我们可以用并查集来表示一个已经归为一种类型的区间,那么对于下一种操作x,y我们可以用vector数组来模拟合并并更新并查集,出于时间复杂度考虑肯定是把小的并到大的上,启发式...原创 2019-03-06 22:26:21 · 299 阅读 · 0 评论 -
CSU 1811 Tree Intersection (树形DP思想+动态开点/主席树思想+启发式合并)
题目链接:http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=1811题目大意:给定一颗树,树上每个节点都有颜色,问对于每条边,其两端子树颜色集合交集的大小。 题目分析:这道题我是看题解才明白的,算是启发式合并的一个入门练习吧。首先想说这道题其实混合了不少思想在里面,我大致觉得有树形DP,线段树/主席树,...原创 2019-02-21 13:16:12 · 237 阅读 · 0 评论