
数据结构-线段树
LucienShui
因为孤独是人之常态,所以陪伴才显得格外可贵。
展开
-
敌兵布阵 - HDU 1166 - 线段树
敌兵布阵 - HDU 1166 - 线段树 C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。原创 2017-05-23 18:02:04 · 206 阅读 · 0 评论 -
UPC-5556 - Black and White - 扫描线 & 线段树
题解链接:https://lucien.ink/archives/134/题目链接:http://exam.upc.edu.cn/problem.php?id=5556题目:题目描述Consider a square map with N × N cells. We indicate the coordinate of a cell by (i, j), w...原创 2018-04-05 19:29:21 · 183 阅读 · 0 评论 -
UPC-5791 - 骑士之战 - 线段树
题解链接:https://lucien.ink/archives/111/题目链接:http://exam.upc.edu.cn/problem.php?id=5791题目:题目描述有n位骑士想要通过淘汰赛决出他们当中最强大的一个。所有的骑士由1到n编号,他们总共进行了m场比赛,在第i场比赛中,所有编号在li到ri之间且尚未出局的骑士进行了一场比赛,决出...原创 2018-02-27 22:04:46 · 352 阅读 · 0 评论 -
洛谷P2471 - 降雨量 - 线段树 + 离散化
链接:https://www.luogu.org/problemnew/show/P2471题目:题目描述我们常常会说这样的话:“X年是自Y年以来降雨量最多的”。它的含义是X年的降雨量不超过Y年,且对于任意Y<Z<X,Z年的降雨量严格小于X年。例如2002,2003,2004和2005年的降雨量分别为4920,5901,2832和3890,则可以说“2005年是自2003年原创 2018-02-01 23:51:32 · 241 阅读 · 0 评论 -
UPCOJ-4124 - SCOI2006 - 动态最值 - 线段树
题目:题目描述有一个包含n个元素的数组,要求实现以下操作:DELETE k:删除位置k上的数。右边的数往左移一个位置。QUERY i j:查询位置i~j上所有数的最小值和最大值。例如有10个元素:QUERY 2 8的结果为2 9。依次执行DELETE 3和DELETE 6(注意这时删除的是原始数组的元素7)后数组变为:QUERY 2 8的结果为1 7。原创 2018-01-22 09:56:13 · 336 阅读 · 0 评论 -
[模板] - 线段树 - Lazy标记 - 单点/区间更新 - 模板
线段树 - Lazy标记 - 单点/区间更新 - 模板目录:前言在这篇文章的代码中用到的宏定义Lazy标记区间更新单点更新模板例题1. 前言: 线段树我花了整整两天的时间去啃,进度很慢,但终究还是坚持下来了,在涉及到Lazy标记的部分卡了很久,刚开始看了一大堆理论,发现很晦涩,也看不懂,后来结合代码一点一点的慢慢就看懂了。2. 在这篇文章的代码中用到的宏定义: PS:注意宏定义部原创 2017-05-26 09:38:11 · 1048 阅读 · 0 评论 -
Mayor's posters - POJ 2528 - 线段树 + 离散
Mayor’s posters - POJ 2528 - 线段树 + 离散 前言:这道坑爹题花了我一天的时间去理解,卡在离散和更新那里,无论怎样都想不明白。最后花了张图,这才终于明白原理。 题目: The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign原创 2017-05-28 00:03:43 · 283 阅读 · 0 评论 -
Vases and Flowers - HDU 4614 - 线段树
Vases and Flowers - HDU 4614 - 线段树题目描述: Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them原创 2017-06-04 09:51:22 · 295 阅读 · 0 评论 -
Transformation - HDU 4578 - 线段树
Transformation - HDU 4578 - 线段树题目描述: Yuanfang is puzzled with the question below: There are n integers, a 1, a 2, …, a n. The initial values of them are 0. There are four kinds of operations. Opera原创 2017-06-02 19:54:22 · 564 阅读 · 0 评论 -
约会安排 - HDU 4553 - 线段树 - 区间合并
约会安排 - HDU 4553 - 线段树 - 区间合并思路 国际惯例中文题目直接说思路,DS QT:找一段最靠前长度为QT的空间;NS QT:找一段最靠前长度为QT的空间,如果没有找到可以将DS占据的空间当做空闲空间,找一段最靠前的空间;STUDY!! L R:清空[L,R]区间的空间。 用两个线段树,一个记录DS,一个记录NS,维护最大左区间ma_l,最大右区间ma_r,以及区间内最大区间m原创 2017-06-04 11:09:46 · 477 阅读 · 0 评论 -
Can you answer these queries? - HDU 4027 - 线段树
Can you answer these queries? - HDU 4027 - 线段树题目: A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Ea原创 2017-05-28 17:13:06 · 436 阅读 · 0 评论 -
Balanced Lineup - POJ 3264 - 线段树
Balanced Lineup - POJ 3264 - 线段树 For the daily milking, Farmer John’s N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee with原创 2017-05-28 16:10:01 · 294 阅读 · 0 评论 -
Color the ball - HDU 1556 - 线段树 区间更新单点查询
Color the ball - HDU 1556 - 线段树 区间更新单点查询 国际惯例中文题目不解释,思路直接裸线段树,Lazy思想入门题。 Lazy传送门:延迟更新详解AC代码://// main.cpp// L//// Created by LucienShui on 2017/5/28.// Copyright © 2017年 LucienShui. All righ原创 2017-05-28 11:22:20 · 518 阅读 · 0 评论 -
Just a Hook - HDU 1698 - 线段树
Just a Hook - HDU 1698 - 线段树题目: 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原创 2017-05-28 11:03:54 · 419 阅读 · 0 评论 -
A Simple Problem with Integers - POJ 3468 - 线段树 区间更新
A Simple Problem with Integers - POJ 3468 - 线段树 区间更新 You have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each numbe原创 2017-05-26 09:42:14 · 313 阅读 · 0 评论 -
I Hate It - HDU 1754 线段树
I Hate It - HDU 1754 线段树 国际惯例中文题目不需要解释题意。 思路:也是个水体,直接裸线段树就可以,没有什么需要注意的地方。写的时候有一个小错误就是刚开始我在本地运行的时候发现Q 1 5一直是零,结果发现是build函数没有写到main里去。AC代码://// main.cpp// L//// Created by LucienShui on 2017/5/2原创 2017-05-24 11:13:05 · 250 阅读 · 0 评论 -
Codeforces 1080F - Katya and Segments Sets - 可持久化线段树
Codeforces 1080F - Katya and Segments Sets - 可持久化线段树题解链接https://lucien.ink题目链接https://codeforces.com/contest/1080/problem/F题目It is a very important day for Katya. She has a test in a programmi...原创 2018-12-09 01:55:32 · 470 阅读 · 0 评论