![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
qq_37383726
这个作者很懒,什么都没留下…
展开
-
Just a Hook 【线段树】-区间更改 求和
Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.原创 2017-04-13 00:40:40 · 227 阅读 · 0 评论 -
【POJ - 2528】Mayor's posters 【离散化+线段树 】
The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally de原创 2017-10-26 22:27:15 · 189 阅读 · 0 评论 -
【2017年浙江中医药大学大学生程序设计竞赛】F 开心的cc 【线段树+思维】
时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 CC is a smart girl and she is curious about everything. One day she starts to analyze her lifestyle and finds out that原创 2017-12-21 20:02:31 · 560 阅读 · 0 评论 -
【哈尔滨理工大学第七届程序设计竞赛决赛(高年级组)】E 求最大值 【线段树+思维】
时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32768K,其他语言65536K 64bit IO Format: %lld 题目描述 给出一个序列,你的任务是求每次操作之后序列中 (a[j]-a[i])/(j-i)【1< = i < j < = n】的最大值。 操作次数有Q次,每次操作需要将位子p处的数字变成y. 输入描述: 本题包含多组输入,每组输入第一行一个原创 2017-12-21 21:13:03 · 301 阅读 · 0 评论 -
【CodeForces - 920F 】SUM and REPLACE 【线段树的区间操作+思维】
Let D(x) be the number of positive divisors of a positive integer x. For example, D(2) = 2 (2 is divisible by 1 and 2), D(6) = 4 (6 is divisible by 1, 2, 3 and 6).You are given an array a of n integ...原创 2018-02-21 18:36:05 · 212 阅读 · 0 评论 -
【计蒜客】 青出于蓝胜于蓝-【dfs序+归并树 】
武当派一共有 nn 人,门派内 nn 人按照武功高低进行排名,武功最高的人排名第 11,次高的人排名第 22,… 武功最低的人排名第 nn。现在我们用武功的排名来给每个人标号,除了祖师爷,每个人都有一个师父,每个人可能有多个徒弟。我们知道,武当派人才辈出,连祖师爷的武功都只能排行到 pp。也就是说徒弟的武功是可能超过师父的,所谓的青出于蓝胜于蓝。请你帮忙计算每个人的所有子弟(包括徒弟的徒弟...原创 2018-03-09 15:13:22 · 244 阅读 · 0 评论 -
I Hate It 【线段树 or 分块】
I Hate It 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0 < N < ...原创 2017-04-11 21:45:59 · 278 阅读 · 0 评论 -
【陕西科技大学第一届程序设计比赛—正式赛】 D E G H J K L S
PS 过的人太多的就不贴代码了(当然过的人很少的我也不会QAQ,有的题如果能够补过的话,还会更新)D 三体——人类的末日之战分析:很明显的 bfs+状态压缩#include<bits/stdc++.h>using namespace std;#define LL long longconst int N = 200+11;const int M = 1...原创 2018-03-12 20:38:13 · 262 阅读 · 0 评论 -
【HDU - 6315】 Naive Operations 【线段树 + 思维】
Naive Operations Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 502768/502768 K (Java/Others) Total Submission(s): 1247 Accepted Submission(s): 521Problem Description In a galaxy far,...原创 2018-07-26 11:02:08 · 152 阅读 · 0 评论 -
【HDU-6356】Glad You Came 【线段树】
Problem Description Steve has an integer array a of length n (1-based). He assigned all the elements as zero at the beginning. After that, he made m operations, each of which is to update an interval...原创 2018-08-07 13:04:40 · 346 阅读 · 0 评论 -
【HDUOJ - 6406】 Taotao Picks Apples 【单调队列 + 线段树(查找区间第一个大于val的位置)】
Problem Description There is an apple tree in front of Taotao’s house. When autumn comes, n apples on the tree ripen, and Taotao will go to pick these apples.When Taotao picks apples, Taotao scans ...原创 2018-08-18 21:11:20 · 281 阅读 · 0 评论 -
【ACM-ICPC 2018 南京赛区网络预赛】 G Lpl and Energy-saving Lamps 【线段树+模拟】
分析: 线段树暴力求解,因为看到了查询中最大的月份才是1e5,那么我们就可以直接模拟求出 1~max(dpdpd_p) 中相应的值,然后逐一回答。 对于当月所可以修的房子,可以用线段树 查找整个所有屋子中第一个小于等于你手中所拥有的灯泡数目 的房子序号,之后还要更新当前房子的灯泡数为INF,表示这个屋子修理过了。 代码中,因为有查找区间第一个大于等于val的模板,所以我直接将值取反,...原创 2018-09-01 20:20:29 · 311 阅读 · 0 评论 -
【POJ 3667】 hotel 【线段树 +区间操作+区间合并】
Hotel Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 14224 Accepted: 6178 Description The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and原创 2017-10-25 22:53:11 · 221 阅读 · 0 评论 -
【HDU - 3911】Black And White 【线段树+区间操作+区间合并】
There are a bunch of stones on the beach; Stone color is white or black. Little Sheep has a magic brush, she can change the color of a continuous stone, black to white, white to black. Little Sheep lik原创 2017-10-24 23:20:37 · 381 阅读 · 0 评论 -
【CF 620E 】New Year Tree 【DFS+线段树+状态压缩】
The New Year holidays are over, but Resha doesn’t want to throw away the New Year tree. He invited his best friends Kerim and Gural to help him to redecorate the New Year tree.The New Year tree is an u原创 2017-10-12 14:13:26 · 508 阅读 · 0 评论 -
A Simple Problem with Integers 【线段树】-区间加减求和
A Simple Problem with Integers 给出了一个序列,你需要处理如下两种询问。“C a b c”表示给[a, b]区间中的值全部增加c (-10000 ≤ c ≤ 10000)。“Q a b” 询问[a, b]区间中所有值的和。Input 第一行包含两个整数N, Q。1 ≤ N,Q ≤ 100000.第二行包含n个整数,表示初始的序列A (-1000000000 ≤ Ai原创 2017-04-13 00:43:48 · 756 阅读 · 0 评论 -
树链剖分 【知识点】+【模板】
知识点讲解链接简单模版 QTREE - Query on a tree You are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3…N-1.We will ask you to perfrom some instructions of the follo原创 2017-06-13 22:45:00 · 229 阅读 · 0 评论 -
玲珑杯” Round #19 Buildings 【线段树+尺取法】+【vector + 尺取法】
分析 一 可以用vector来维护区间的 有序性,从而找到最大值和最小值。 代码#include<bits/stdc++.h>#define LL long longusing namespace std;const int MAXN =1e6+100;int arr[MAXN];vector<int>ve;int main(){ int n,k; while(sca原创 2017-07-30 10:12:29 · 201 阅读 · 0 评论 -
【51 nod 1019 】 逆序对 【归并排序】or【线段树】
1019 逆序数在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。 如2 4 3 1中,2 1,4 3,4 1,3 1是逆序,逆序数是4。给出一个整数序列,求该序列的逆序数。 Input 第1行:N,N为序列的长度(n <= 50000) 第2 - N + 1行:序列中的元素(0 <= A[i] <=原创 2017-07-31 18:08:20 · 175 阅读 · 0 评论 -
【NYOJ 116】士兵杀敌(二) 【树状数组 or 线段树 】
线段树代码#include<bits/stdc++.h>using namespace std ;#define ll o<<1#define rr o<<1|1#define lson o<<1,le,mid#define rson o<<1|1,mid+1,ritypedef long long LL ;const int MAXN = 1000000+100;const in原创 2017-08-17 09:58:04 · 225 阅读 · 0 评论 -
【ZZULIOJ 2171 】 举世伐唐 【线段树 区间修改+区间最大值】
Description夫子将人间之气注入桑桑体内后,便再也无法隐瞒踪迹,昊天终于发现了他。 “恭请夫子显圣!” 西陵神国桃山最高处,庄严肃穆的神殿外,石坪上跪着黑压压的人群,往常骄横的红衣神官和神殿执事们。就像最虔诚的信徒,以额触地。 “恭请夫子显圣!” 极西荒原深处,天坑中央的巨峰之巅。悬空寺讲经首座的手中没有握着锡杖,而是诚心诚意地双手合什,无比恭敬地祝祷着。原创 2017-08-06 21:03:43 · 602 阅读 · 0 评论 -
敌兵布阵 【线段树 or 树状数组 区间求和】
敌兵布阵 C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演原创 2017-04-11 21:42:56 · 238 阅读 · 0 评论 -
Color the ball 【线段树】+区间更新求和
Color the ballTime Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19188 Accepted Submission(s): 9585Problem Description N个气球排成一排,从左到右依次编号为1,2,3原创 2017-04-12 23:39:17 · 224 阅读 · 0 评论 -
【HDU 5023】A Corrupt Mayor's Performance Art 【线段树+状态压缩】
Corrupt governors always find ways to get dirty money. Paint something, then sell the worthless painting at a high price to someone who wants to bribe him/her on an auction, this seemed a safe way for原创 2017-10-27 16:04:17 · 212 阅读 · 0 评论 -
【HDU - 3308】 LCIS 【线段树+单点更新+区间合并】
Given n integers. You have two operations: U A B: replace the Ath number by B. (index counting from 0) Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b].原创 2017-10-09 23:47:58 · 308 阅读 · 0 评论 -
【HDU - 1540】Tunnel Warfare 【线段树+单点更新+区间合并】
During the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay in a line. Except th原创 2017-10-23 18:16:36 · 921 阅读 · 0 评论 -
[牛客国庆集训派对Day1] C[数学] L[最短路] J[线段树]
比赛链接C链接:https://www.nowcoder.com/acm/contest/201/C来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 1048576K,其他语言2097152K64bit IO Format: %lld题目描述算术是为数不多的会让Kuon感到棘手的事情。通常她会找Haku帮忙,但是Haku已经被她派去买东西了。于是她向你寻求帮...原创 2018-10-02 09:44:57 · 341 阅读 · 0 评论