![](https://img-blog.csdnimg.cn/2019091813595558.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构:线段树/树状数组
数据结构:线段树/树状数组
LSD20164388
如果你过几天就忘了,那么你并没有真正的掌握。
展开
-
2019-2020 ICPC香港 C. Constructing Ranches (点分治)
传送门题意TTT组数据,每组数据给你一个正整数nnn,然后每个点的权值aia_iai,再给你n−1n-1n−1条无向边(ui,vi)(u_i,v_i)(ui,vi),保证构成一棵树。求有多少条合法的路径(相当于多少个点对),使得路径上经过的所有点的权值可以构成一个简单多边形。数据范围:1⩽n⩽2×105,1⩽ai⩽1091\leqslant n\leqslant 2\times10^5,1\leqslant a_i\leqslant 10^91⩽n⩽2×105,1⩽ai⩽1091⩽ui,原创 2020-12-15 20:11:37 · 590 阅读 · 0 评论 -
Educational Codeforces Round 90 (Rated for Div. 2) G. Pawns (线段树)
G. Pawnstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a chessboard consisting ofnnrows andnncolumns. Rows are numbered from bottom to top from11tonn. Columns are...原创 2020-07-03 14:30:08 · 261 阅读 · 0 评论 -
HDU 6240 Server(2017CCPC哈尔滨 K)01分数规划+树状数组优化dp
题目传送门ServerTime Limit: 20000/10000 MS (Java/Others)Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1540Accepted Submission(s): 256Problem DescriptionAlice and Bob are working on a new assignment. In this project, they nee...原创 2020-06-20 12:46:53 · 252 阅读 · 0 评论 -
Codeforces Round #638 (Div. 2) F. Phoenix and Memory(贪心+线段树)
F. Phoenix and Memorytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPhoenix is trying to take a photo of hisnnfriends with labels1,2,…,n1,2,…,nwho are lined up in a row in a speci...原创 2020-05-08 18:41:09 · 322 阅读 · 0 评论 -
Codeforces Round #625 (Div. 2, based on Technocup ...) E. World of Darkraft: Battle for(线段树)
题目链接E. World of Darkraft: Battle for Azathothtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputRoma is playing a new expansion f...原创 2020-03-06 00:46:32 · 244 阅读 · 0 评论 -
2016年ACM/ICPC大连赛区 E题(阅读理解+树状数组原理)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5749题意:题意是个啥?我怎么读不懂?这道题没过的都是因为没读懂题吧!!!!!!简直考阅读理解啊!!!赛后参考(茶飘香~)大佬的博客终...原创 2018-10-03 17:11:27 · 313 阅读 · 2 评论 -
HDU 6274 Master of Sequence(思维+树状数组+二分)
题意:给你n,m。接下来n个数,给出a[i]。再接下来n个数,给出b[i]。m次查询,每次查询:若 id=1 则给出 x y 把a[i]的值修改为y。若 id=2 则给出 x y 把b[i]的值修改为y。若 id=3 则给出 k 求,其中思路:求S(t)>=k最小的t 显然是二分。注意S(t)这个式子。我们每次从1~n求的话,复杂度n*m会...原创 2018-10-18 21:24:17 · 310 阅读 · 0 评论 -
Educational Codeforces Round 56 (Rated for Div. 2) G. Multidimensional Queries(状压+线段树)
G. Multidimensional Queriestime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array aa of nn points in kk-dimensio...原创 2018-12-18 19:06:34 · 246 阅读 · 2 评论 -
HDU 5493 Queue 二分+树状数组
QueueTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1553 Accepted Submission(s): 798 Problem DescriptionN people numbered from 1 to ...原创 2019-01-16 10:59:01 · 371 阅读 · 0 评论 -
2019年2月14日训练日记
线段树/树状数组小结:1、基本问题:区间更新(加、变、取反等)区间查询最值、和(可以加一些限制条件,这是树状数组做不了的),最长连续序列长度。看见多少张海报、所有海报的总面积、周长等。在只有一次查询的情况下,可以考虑前缀和。2、基本变式:对某些求和更新操作增加条件,或者查询一些有限制的东西。可能用到二分。这个时候思维就要灵活一些,对线段树的更新、查询等操作做适当的修改。难一点可以结合许多其...原创 2019-02-15 08:38:12 · 205 阅读 · 0 评论 -
2019年ICPC南昌网络赛 J. Distance on the tree(树链剖分+树状数组)
题目链接:https://nanti.jisuanke.com/t/38229DSM(Data Structure Master) once learned about tree when he was preparing for NOIP(National Olympiad in Informatics in Provinces) in Senior High School. So when...原创 2019-04-22 16:06:50 · 526 阅读 · 0 评论 -
HDU 6521 Party(吉司机线段树)
PartyTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 87Accepted Submission(s): 26Problem Descriptionnperson have just entered a co...原创 2019-04-20 10:39:45 · 853 阅读 · 4 评论 -
2015年ACM/ICPC沈阳赛区 I题(二维树状数组)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5258题意:给你n(n<=1e5)个正整数二元组<a,b> (1<=a,b<=1e5)给你m(m<=1e5...原创 2018-10-02 21:52:00 · 316 阅读 · 0 评论 -
ACM-ICPC 2018 焦作赛区网络预赛 E 树链剖分 + 多重标记
You ye Jiu yuan is the daughter of the Great GOD Emancipator. And when she becomes an adult, she will be queen of Tusikur, so she wanted to travel the world while she was still young. In a country, sh...原创 2018-09-18 17:21:13 · 224 阅读 · 0 评论 -
2018年6月14日训练日记
这几天主要是做了新开的“区间数据维护”专题。dp专题是真的治不动啊。。。想好几天够呛想出一道题,看题解也得琢磨两天才能弄懂,有的题目还没有题解。。。虽然都是刘汝佳的那本训练指南(蓝书和紫书)上的题目,有一定的题解,但是要过掉这道题目还是不简单(除非你真正理解透了)。不过既然时间延长了四天,应该还可以再拼一两道题。。。(这种难度的题目还是做的太少了,不过见过一遍也好,但是头发一开始掉就停不下来了。。...原创 2018-06-14 21:25:17 · 191 阅读 · 0 评论 -
UVA - 1513 Movie collection(树状数组)
题意:给你一摞共n(n<=1e5)个光盘,刚开始从下到上依次是光盘n,n-1,n-2,...,1号。现在出题人要看m(m<=1e5)次光盘,每一次都会抽出光盘a[i]号并放到最上面。让你求每一次抽出光盘a[i]时,抽出的光盘上方有几个光盘。思路:树状数组。容易想到抽出一个光盘,然后对于在其上面的每一个光盘,在它上面的光盘数都会增加1,因此只需要记录一下每个光盘的位置,然后树状数组开大一...原创 2018-06-14 21:35:28 · 188 阅读 · 0 评论 -
UVA - 11992 Fast Matrix Operations (线段树)
题意:给一个r行c列的矩阵(r<=20,r*l<=1e6),初始化都为0,三种操作:1 r1 c1 r2 c2 v 把矩阵(r1,c1)到(r2,c2)的元素全加上v2 r1 c1 r2 c2 v 把矩阵(r1,c1)到(r2,c2)的元素全变成v3 r1 c1 r2 c2 求矩阵(r1,c1)到(r2,c2)的元素的和、最小值、最大值这道题简直就是为了让我们写一个线段树基...原创 2018-06-16 10:37:39 · 201 阅读 · 0 评论 -
HDU 5306 Gorgeous Sequence(线段树)
Gorgeous SequenceTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 4481 Accepted Submission(s): 1209 Problem DescriptionThere is a se...原创 2018-07-16 19:35:34 · 181 阅读 · 0 评论 -
例题:区间更新一次查询(前缀和)
题目: 喵哈哈村的种花魔法(前缀和(单点更新,区间查询))描述喵哈哈村有一个谷歌廖,谷歌廖特别喜欢种花。而且谷歌廖最神奇的就是,他会施展一种种花魔法,会使得一定区间的花儿,长高k 厘米。在谷歌廖施展若干次魔法之后,好奇的沈宝宝想知道,每朵花儿的高度是多少。输入第一行两个整数n,m,分别表示花儿的数量,和谷歌廖施展种花魔法的次数。第二行n个整数a[i],表示花儿一开始的高度...原创 2018-07-23 10:00:51 · 924 阅读 · 0 评论 -
HDU 5323 Solve this interesting problem(DFS)
Solve this interesting problemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3297 Accepted Submission(s): 1058 Problem DescriptionHa...原创 2018-07-21 08:43:41 · 239 阅读 · 0 评论 -
HDU 5316 Magician(线段树区间合并)
MagicianTime Limit: 18000/9000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3745 Accepted Submission(s): 989 Problem DescriptionFantasy magicians usuall...原创 2018-07-22 15:43:07 · 279 阅读 · 0 评论 -
HDU 6393 Traffic Network in Numazu(LCA+思维+(树上差分)树状数组)
Traffic Network in NumazuTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 239 Accepted Submission(s): 87 Problem DescriptionChika is...原创 2018-08-14 10:10:35 · 235 阅读 · 0 评论 -
牛客练习赛25 B 最长区间
链接:https://www.nowcoder.com/acm/contest/158/B来源:牛客网 最长区间时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述给你一个长度为 n 的序列 a ,求最长的连续的严格上升区间的长度。同时会进行 m 次修改,给定 x , y ,...原创 2018-08-25 08:54:30 · 386 阅读 · 0 评论 -
ACM-ICPC 2018 南京赛区网络预赛 G 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-03 14:51:02 · 193 阅读 · 0 评论 -
UVA - 1232 SKYLINE (线段树)
题意:现在要建n(n<1e5)个建筑,每个建筑都有相应的长宽高,用l、r、h表示(l,r<1e5 h<1e9)。这n个建筑是要按给定顺序建立的,求 每个建筑刚建完时 这个建筑的高度 是 已经建完的所有建筑高度中 最高高度 的长度 的和。思路:线段树。维护区间最大h。做一个标记flag记录此处是否有建筑。然后根据不同情况处理。注意向上更新和向下更新时的修改。一个点l表示区间[l,l...原创 2018-06-21 10:37:32 · 255 阅读 · 0 评论