![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树/zkw线段树
c++
等我学会后缀自动机
侠影之谜
展开
-
CodeForces 315E Sereja and Subsequences (权值线段树+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-25 22:46:27 · 115 阅读 · 0 评论 -
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 · 142 阅读 · 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 · 164 阅读 · 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 评论 -
CodeForces - 115E Linear Kingdom Races (线段树优化DP)*
题目链接:http://codeforces.com/problemset/problem/115/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 ll lon...原创 2018-11-10 16:43:30 · 212 阅读 · 0 评论 -
HDU 4666 Hyperspace (曼哈顿距离+线段树维护极值)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4666#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 lon...原创 2018-10-26 16:17:32 · 264 阅读 · 0 评论 -
Codeforces 522D Closest Equals (线段树+DP+离线)*
题目链接:http://codeforces.com/problemset/problem/522/D#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-09-30 10:00:16 · 180 阅读 · 0 评论 -
Codeforces 474E Pillars (线段树+DP+二分+离散)
题目链接:http://codeforces.com/problemset/problem/474/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...原创 2018-09-29 23:46:42 · 148 阅读 · 0 评论 -
Codeforces 834D The Bakery (线段树+DP)
题目链接:http://codeforces.com/problemset/problem/834/D#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-09-29 11:40:07 · 197 阅读 · 0 评论 -
Codeforces 834D The Bakery (线段树+DP+单调性质)*
题目链接:https://cn.vjudge.net/problem/CodeForces-834D#include<bits/stdc++.h>#pragma comment(linker,"/STACK:1024000000,1024000000")using namespace std;#define debug puts("YES");#define rep(x...原创 2018-09-08 09:21:27 · 141 阅读 · 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 · 155 阅读 · 0 评论 -
CodeForces 75D Big Maximum Sum (线段树辅助DP)
题目链接:http://codeforces.com/problemset/problem/75/D#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 __i...原创 2018-12-05 07:44:52 · 160 阅读 · 0 评论 -
Gym 100712L Alternating Strings II (线段树+DP)
题目链接:http://codeforces.com/gym/100712/attachments#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 ...原创 2019-01-23 08:06:15 · 125 阅读 · 0 评论 -
Codeforces Global Round 1 F. Nearest Leaf(线段树+离线操作)*
题目链接:http://codeforces.com/contest/1110/problem/F题目大意:统计查询类题目,给定一颗树,树边有权重,查询格式是:x,y,z,查询x节点到[y,z]区间中的叶节点的最短路径长度是多少。其树的产生形式严格遵循DFS序形式。题目分析: 这道题我是瞄了眼题解的思路的,才知道有个换根的性质。大体是这样的:首先考虑所有的x都是1根节...原创 2019-02-21 23:51:51 · 157 阅读 · 0 评论 -
Codeforces Round #538 (Div. 2)F Please, another Queries on Array? (数论+线段树+状态压缩)
题目链接:http://codeforces.com/contest/1114题目大意:查询结构,初始给定一个序列,支持两种操作,一种是 在区间上每个数都乘上一个x,一种是查询区间上每个数累乘后的结果的欧拉函数。题目分析: 这道题应该是 比较简单的,主要感觉还是考验代码功底吧。观察欧拉函数的性质即可,euler(n)=n*{因子乘积(1-1/p)}形式,打表发现...原创 2019-02-17 10:37:00 · 373 阅读 · 0 评论 -
Codeforces Round #546 (Div. 2) E. Nastya Hasn't Written a Legend(线段树+二分+数学转换)
题目链接:http://codeforces.com/contest/1136/problem/E题目大意给定两个序列,支持两种操作,查询第一个序列的区间和,第二种是修改a数组x位置上的值,增加x,并且如果a[i+1]<a[i]+k[i] 那么a[i+1]=a[i]+k[i]。题目分析[i+1]-S[i]<a[i]-S[i-1],这样我们把a[i]+S[i...原创 2019-03-21 00:52:03 · 123 阅读 · 0 评论 -
CodeForces 1000F One Occurrence (线段树+离线/主席树)*
题目链接:http://codeforces.com/problemset/problem/1000/F题目大意给定一个序列和若干个查询,每次查询区间中只出现一次的那个数字,若答案有若干个则输出任意一个,否则输出零。题目分析根据贪心的思想,对于一个特定的区间,假设每个位置都有一个pre,即上一次出现该位置数的位置,如果第一次出现明显位置应该为0,一个区间中是否存...原创 2019-03-19 14:25:48 · 290 阅读 · 0 评论 -
Educational Codeforces Round 61 (Rated for Div. 2) G Greedy Subsequences (线段树+单调栈+DFS序)*
题目链接:http://codeforces.com/contest/1132题目大意定义一个贪心子序列为:一个子序列下标集合并且满足题目中给定的条件,给定n和k,输出n-k个数字,有n-k个滑动区间,每个对应该区间中最大贪心子序列的长度.题目分析可以说是蛮自闭的题目了,,,看别人的提示外加自己研究好久才终于弄明白了.首先是建图的思想,不难发现对于这个关系来说是...原创 2019-04-10 19:12:52 · 81 阅读 · 0 评论 -
HDU 6521 Party(线段树+二分+思维贡献)*
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6521题目大意给定n和m个操作,n代表序列长度,每个操作给定一个区间,代表把这个区间的人聚到一起,其区间效率是这个区间中多少对人没有在之前的区间中已经聚过.题目分析线段树+思维转化,我们可以对每个人,维护一个数组代表其最远认识到右边的哪一个人,比如...原创 2019-04-25 17:11:50 · 208 阅读 · 0 评论 -
ACM-ICPC 2018 南京赛区网络预赛 Lpl and Energy-saving Lamps(线段树基础)
During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon imprisoned Lpl in the Castle? Dragon smiled enigmatically and answered that it is a big secret. A...原创 2018-09-02 15:43:27 · 339 阅读 · 0 评论 -
Codeforces round 19D Points(离线处理+Set集合的运用+离散化数据)好题
Pete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (0, 0) is located in the bottom-left corner, Ox axis is direc...原创 2018-08-21 08:42:17 · 153 阅读 · 0 评论 -
HDU 6447 YJJ's Salesman (线段树优化DP)
#pragma comment(linker, "/STACK:102400000,102400000")#include<bits/stdc++.h>using namespace std;#define debug puts("YES");#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)#define lrt ...原创 2018-08-28 08:57:58 · 204 阅读 · 0 评论 -
HDU 3887 Counting Offstring (DFS序+线段树结构模板题)*
Counting OffspringTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3457 Accepted Submission(s): 1181Problem Description You are given a tree,...原创 2018-07-15 10:57:51 · 161 阅读 · 0 评论 -
Codeforces 877E Danil and a Part-time Job(DFS序构造线段树+区间维护)*
Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.Danil works in a rooted tree (undirected connected acyclic graph) with ...原创 2018-07-20 08:09:05 · 146 阅读 · 0 评论 -
HDU 3887 Counting Offspring (DFS序构造+线段树)*
Counting OffspringTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3472 Accepted Submission(s): 1184 Problem DescriptionYou are given...原创 2018-07-19 12:01:44 · 181 阅读 · 0 评论 -
Codeforces Round Educational C. Covered Points Count (维护区间和)
C. Covered Points Counttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given nn segments on a coordinate line; each endpoint of every segm...原创 2018-06-29 11:13:48 · 546 阅读 · 0 评论 -
HDU 4893 Wow!Such a sequence!(线段树+斐波那契二分)
Wow! Such Sequence!Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 4884 Accepted Submission(s): 1425Problem Description Recently, Doge go...原创 2018-06-22 10:01:26 · 222 阅读 · 0 评论 -
HDU 4339 Query(线段树+搜索技巧)
QueryTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3274 Accepted Submission(s): 1078Problem Description You are given two strings s1[0..l...原创 2018-05-22 18:42:27 · 331 阅读 · 0 评论 -
HDU 3308 LCIS (线段树区间合并)
LCIS Time Limit : 6000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 1 Accepted Submission(s) : 1Font: Times New Roman | Verdana | Georgia Font Size: ← →Probl...原创 2018-05-22 15:46:41 · 157 阅读 · 0 评论 -
HDU 3577 Fast Arrangement (简单线段树lazy)
Fast ArrangementTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3561 Accepted Submission(s): 1024Problem Description Chinese always have the ...原创 2018-05-12 16:11:56 · 148 阅读 · 0 评论 -
HDU 4747 Mex(线段树维护mex)经典
MexTime Limit: 15000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 3851 Accepted Submission(s): 1278 Problem DescriptionMex is a function on a se...原创 2018-08-09 07:11:58 · 960 阅读 · 0 评论 -
HDU 6315 Naive Operations(线段树单点更新配合区间更新+思维)*
Naive OperationsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others)Total Submission(s): 2271 Accepted Submission(s): 987 Problem DescriptionIn a galaxy far...原创 2018-07-28 08:55:49 · 397 阅读 · 1 评论 -
HDU 4666 Hyperspace (线段树+曼哈顿距离+离线查询)
HyperspaceTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1450 Accepted Submission(s): 708 Problem DescriptionThe great Mr.Smith ha...原创 2018-08-20 08:12:23 · 195 阅读 · 0 评论 -
ZOJ 3911 Prime Query (线段树基本操作)
Prime QueryTime Limit: 5 Seconds Memory Limit: 196608 KBYou are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence.Here are ...原创 2018-08-20 00:21:00 · 194 阅读 · 0 评论 -
Codeforces 343D Water Tree(线段树+DFS序)*
Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water.The vertices of the tree are numbered from 1...原创 2018-08-16 15:26:52 · 122 阅读 · 0 评论 -
HDU 5489 Removed Interval (离散化数据建树+线段树+滑动窗口)*
Removed IntervalTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2223 Accepted Submission(s): 700 Problem DescriptionGiven a sequence ...原创 2018-08-16 06:48:44 · 176 阅读 · 0 评论 -
Codeforces 877E Danil and a Part-time Job (DFS序+线段树)
Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.Danil works in a rooted tree (undirected connected acyclic graph) with ...原创 2018-08-18 16:45:57 · 222 阅读 · 0 评论 -
HDU 4614 Vases and Flowers (线段树+二分)
Vases and FlowersTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 4695 Accepted Submission(s): 1934 Problem Description Alice is so p...原创 2018-08-15 19:08:14 · 98 阅读 · 0 评论 -
HDU 1540 Tunnel Warfare (线段树单点更新+思维)
Tunnel WarfareTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12857 Accepted Submission(s): 5083 Problem DescriptionDuring the War of...原创 2018-08-12 22:02:25 · 115 阅读 · 0 评论 -
HDU 3016 Man Down (线段树维护最值+DP思想)
Man DownTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2869 Accepted Submission(s): 1043 Problem DescriptionThe Game “Man Down 100 f...原创 2018-08-12 08:16:00 · 223 阅读 · 0 评论