![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
其他OJ习题集
等我学会后缀自动机
侠影之谜
展开
-
P2444 [POI2000]病毒(AC自动机模板+)
#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-28 11:40:04 · 161 阅读 · 0 评论 -
P5357 【模板】AC自动机(二次加强版)(树上差分+AC自动机)
#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-24 20:53:57 · 170 阅读 · 0 评论 -
P3796 【模板】AC自动机(加强版)(AC自动机模板)
#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-24 00:23:38 · 173 阅读 · 0 评论 -
P3808 【模板】AC自动机(简单版)(AC自动机模板)
#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-24 00:02:45 · 163 阅读 · 0 评论 -
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 · 122 阅读 · 0 评论 -
P3377 【模板】左偏树(可并堆)
#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-19 18:01:22 · 160 阅读 · 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 · 113 阅读 · 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 · 106 阅读 · 0 评论 -
HYSBZ 3224 Tyvj 1728 普通平衡树(FHQ_Treap平衡树)
#include<bits/stdc++.h>using namespace std;#define ls(x) ch[x][0]#define rs(x) ch[x][1]const int maxn=1e5+10;int tot,root;int ch[maxn][2],val[maxn],dat[maxn],sz[maxn];void upd(int x){ ...原创 2020-01-21 17:18:31 · 122 阅读 · 0 评论 -
HYSBZ 3224 Tyvj 1728 普通平衡树
#include<bits/stdc++.h>using namespace std;#define ls ch[x][0]#define rs ch[x][1]#define R register intconst int maxn=1e5+10,Inf=2e9+10;inline int input(){ R ret=0,fix=1; register...原创 2020-01-20 17:39:19 · 118 阅读 · 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 · 182 阅读 · 0 评论 -
POJ 1149 PIGS (网络流建模思维+好题)*
题目链接:http://poj.org/problem?id=1149题目大意题目意思有些鬼畜我感觉,大体意思就是:有个访客序列,每个访客可以打开指定的猪圈序列,然后对于当前已经打开的猪圈其猪的个数可以任意分配,每个访客固定要拿走指定头猪,问最多可以有多少头猪可以被拿走。题目分析网络流建模问题,增加源点指向猪圈,这道题建模的关键在于是选择选取猪圈为点还是访客,如...原创 2019-03-11 20:45:22 · 134 阅读 · 0 评论 -
POJ 1240 Pre-Post-erous! (递归+组合数学)
题目链接:http://poj.org/problem?id=1240题目大意给定两个m叉树的先序排列和后序排列,问能有多少种可能的树使得这个序列合法。题目分析递归+组合数学。设定状态:(l1,r1,l2,r2),那么我们不难发现l1下标对应的数在第二个区间中出现的下标为L3,那么这样状态就可以划分了,明显(l1+1,l1+l3-l2,l2,l2,l3-1)是一个...原创 2019-03-03 11:40:52 · 354 阅读 · 0 评论 -
CSU 1811 Tree Intersection (树形DP思想+动态开点/主席树思想+启发式合并)
题目链接:http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=1811题目大意:给定一颗树,树上每个节点都有颜色,问对于每条边,其两端子树颜色集合交集的大小。 题目分析:这道题我是看题解才明白的,算是启发式合并的一个入门练习吧。首先想说这道题其实混合了不少思想在里面,我大致觉得有树形DP,线段树/主席树,...原创 2019-02-21 13:16:12 · 175 阅读 · 0 评论 -
CSU 1811 Tree Intersection (map启发式合并+树形DP)
题目链接:http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=1811题目大意:给定一颗树,树上每个节点都有颜色,问对于每条边,其两端子树颜色集合交集的大小。题目分析: 相比于上次用线段树动态开点类似的方法来做合并,这次用map做启发式合并,这样的复杂度会因为每次都合并小的而降维。这道题同时还嵌套着树形D...原创 2019-02-24 09:36:53 · 158 阅读 · 0 评论 -
POJ 3734 Blocks (指数母函数)
题目链接:http://poj.org/problem?id=3734#include<cstdio>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...原创 2019-02-09 23:59:35 · 167 阅读 · 0 评论 -
POJ 2389 Bull Math (FFT模板题)
题目链接:http://poj.org/problem?id=2389#include<iostream>#include<cstring>#include<cmath>#include<cstdio>using namespace std;#define debug puts("YES");#define rep(x,y,z) ...原创 2019-02-03 21:37:52 · 181 阅读 · 0 评论 -
LightOJ 1125 Divisible Group Sums (简单DP)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1125题目大意:给定n个数,要求选m个数使得其和被k整除,问选法的个数。题目分析: 题目分析:由于范围很小,直径二暴力DP即可,但还要注意序列中的数可能为负数的情况,取模的时候再注意下即可。#include<iostream>#includ...原创 2019-02-14 19:05:51 · 112 阅读 · 0 评论 -
HRBUST 1846 方格涂色 (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...原创 2018-12-04 00:07:53 · 511 阅读 · 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 · 186 阅读 · 0 评论 -
蓝桥杯 历届试题 小数第n位(数学)
题目链接:http://lx.lanqiao.cn/problemset.page?code=PREV-&userid=162162#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2019-03-23 19:07:21 · 151 阅读 · 0 评论 -
蓝桥杯 历届试题 对局匹配(DP)
题目链接:http://lx.lanqiao.cn/problemset.page?code=PREV-&userid=162162#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2019-03-23 19:08:21 · 211 阅读 · 0 评论 -
蓝桥杯 历届试题 发现环(DFS)
题目链接:http://lx.lanqiao.cn/problemset.page?code=PREV-&userid=162162#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x...原创 2019-03-23 19:34:05 · 194 阅读 · 0 评论 -
徐州网络赛 G Trace (思维题+set集合性质)
题目链接:https://nanti.jisuanke.com/t/31459#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(i...原创 2018-09-11 12:06:50 · 197 阅读 · 0 评论 -
2019 西安邀请赛 And And And(计数+树形DP)
题目链接:https://www.jisuanke.com/contest/2625#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#...原创 2019-05-26 19:52:47 · 197 阅读 · 0 评论 -
HYSBZ 1008 越狱 (组合数学+DP)
考虑前两个,如果两个一样,那么就是m^(n-1),不一样的话就是f(n-1),式子:f(n)=f(n-1)*(m-1)+m^(n-1),不难凑出:(f(n)-m^n)=(f(n-1)-m^(n-1))(m-1).f(2)为m.#include<bits/stdc++.h>using namespace std;#define debug puts("YES"...原创 2019-05-12 19:39:25 · 135 阅读 · 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 · 144 阅读 · 0 评论 -
POJ 2800 Joseph's Problem (数论分块)
最后是要求sigma k%i,i从1到n,转换为k-k/i*i,明显这个东西可以分块求,时间复杂度是根号级别的,即从i到k/(k/i)这个区间所对应的k/i都是一样的,然后变化的是i部分可以等差数列求和O(1)得出.#include<iostream>#include<cmath>#include<algorithm>using ...原创 2019-05-07 07:18:18 · 150 阅读 · 0 评论 -
南昌邀请赛 网络赛 MORE XOR(规律+前缀异或和)
题目链接:https://nanti.jisuanke.com/t/38230题目大意给定一个序列,层层定义三个函数,定义都是数学式子很复杂,但是终归就是每一位的数取还是不取的关系.题目分析第一层:1,1,1,1,1第二层:1,0,1,0,1,事实上就是上一层前缀和模2,第三层:1,1,0,0,1,1,0,0,...到这里即可,那么分析,对于(l,r...原创 2019-04-21 11:45:02 · 223 阅读 · 9 评论 -
南昌邀请赛 计蒜客 Subsequence(多链表)
题目链接:https://nanti.jisuanke.com/t/38232多链表签到#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 l...原创 2019-04-21 06:58:48 · 158 阅读 · 0 评论 -
南昌邀请赛 Max answer(单调栈+最小子段和)
题目链接:https://nanti.jisuanke.com/t/38228题目大意给定一个正负数的串,定义一个函数f(l,r)=(r-l+1)*min{a[i]|l<=i<=r},问这个函数的最大值是多少.题目分析首先对于最小值是整数的情况,用单调栈很好维护,那么剩下的负数的情况,不难发现其所要找的子段和是最小的,就是说答案如果是以负数作...原创 2019-04-21 06:56:09 · 166 阅读 · 0 评论 -
HYSBZ 1483 梦幻布丁 (启发式合并)
题目链接:https://vjudge.net/problem/134273/origin题目大意中文题目,不过多解释了题目分析启发式合并,据说模拟两个数据结构合并的过程中用容量小的去加入容量大的的话可以把复杂度降低为nlogn.对于这道题,我们维护以颜色为标记的链表,用vector存储各个相同颜色的下标,并且映射关系逻辑要理清楚,因为我们通过启发式合并可能把颜色...原创 2019-03-28 18:58:07 · 146 阅读 · 0 评论 -
POJ 3252 Round Numbers (数位DP)
题目链接:https://vjudge.net/problem/20836/origin题目大意给定一个区间,要求这个区间内满足条件的数的个数;条件是:二进制表示其0的个数不小于1的个数。题目分析把之前的十进制转换为二进制即可,注意前缀零的判定,搜索参数要多加一维,其余的没什么变化。#include<iostream>#include<cs...原创 2019-04-01 14:56:21 · 123 阅读 · 0 评论 -
牛客网练习赛27 E 欧拉(积性函数)
题目链接:https://www.nowcoder.com/acm/contest/188/E#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,y) ...原创 2018-09-27 18:46:42 · 215 阅读 · 0 评论 -
BZOJ 3944 Sum (积性函数前缀和杜教筛)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=3944#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define...原创 2018-10-12 08:39:08 · 161 阅读 · 0 评论 -
ACM-ICPC 2018 徐州赛区网络预赛F. Features Track (数据结构map的使用)
题目链接:https://nanti.jisuanke.com/t/31458#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(i...原创 2018-09-09 23:51:32 · 178 阅读 · 0 评论 -
ACM-ICPC 2018 徐州赛区网络预赛 I Characters with Hash (模拟水题)
题目链接:https://nanti.jisuanke.com/t/31461#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(in...原创 2018-09-09 22:16:52 · 103 阅读 · 0 评论 -
ACM-ICPC 2018 徐州赛区网络预赛 徐州 H Ryuji doesn't want to study (树状数组维护前缀和)水题
题目链接:https://nanti.jisuanke.com/t/31460#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(i...原创 2018-09-09 21:24:25 · 185 阅读 · 0 评论 -
沈阳网络赛 C Convex Hull (莫比乌斯反演+推公式+快速乘)*
题目链接:https://nanti.jisuanke.com/t/31444#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(i...原创 2018-09-09 08:38:16 · 484 阅读 · 0 评论 -
徐州网络赛 A Hard to prepare (组合数学计数)*
题目链接:https://nanti.jisuanke.com/t/31453#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x,y,z) for(i...原创 2018-09-12 00:51:56 · 289 阅读 · 0 评论