【整理】线段树30题

1,poj 1151 Atlantis: 求矩形面积并。

2,poj 1177 Picture: 求矩形轮廓的周长。

3,poj 1389 Area of Simple Polygons :同第一题。

4,poj 1823 Hotel :线段树线段的插入删除求线段树中最长的线段长度

5,poj 2104 K-th Number:线段树维护归并排序树+三次二分查找   (区间第k大 ,主席树也行,前者可以练习试一下)。

6,poj 2155 Matrix :求二维平面的矩形信息,二维线段树,或者二维树状数组。

7,poj 2299 Ultra-QuickSort:  求逆序对,事实上,线段树可以求逆序对,还可以求最长上升子序列。

8,poj 2352 Stars : 线段树入门题。

9,poj 2482 Stars in Your Window : 扫描线 +离散化 +线段树。

10,poj 2528 Mayor‘s posters :线段树染色问题。

11,poj 2761 Feed the dogs :区间第k大。

12,poj 2777 Count Color:线段树染色问题,颜色少,用二进制表示即可,上传的时候并一下即可;颜色多了我们也可以用bitset的并搞定。

13,poj 2823 Sliding Window:线段树解决滑动窗口问题。

14,poj 2828 Buy Tickets:逆序即可。

15,poj 2886 Who Gets the Most Candies?:约瑟夫环的升级版本(*)

16,poj 3264 Balanced Lineup: 求RMQ

17,poj3277 City Horizon:set+pair构造线段树(*)

18,poj 3468 A Simple Problem with Integers:会lazy标记即可。

19,poj 3667 Hotel :线段树区间处理(*)

20,poj 3695 Rectangles :矩形面积并。

21,hdu 1255 覆盖的面积 :求覆盖两次以上部分的面积并。

22,hdu 3642 Get The Treasury: 求三维的面积并。

23,spoj 375 Query on a tree:  求树上两点间最大边权 树剖+线段树

24,hihocoder 1046 : K个串:统计所有连续序列,求出其不重复数值和,求第k大。(*)

25,CF 915E: Physical Education Lessons,动态的处理线段树。 (*)

mama,说好的30题,快推荐点好题,我再补充呗。

原文地址:https://www.cnblogs.com/hua-dong/p/8295924.html

时间: 2024-08-19 11:43:45

【整理】线段树30题的相关文章

POJ 3468 线段树裸题

这些天一直在看线段树,因为临近期末,所以看得断断续续,弄得有些知识点没能理解得很透切,但我也知道不能钻牛角尖,所以配合着刷题来加深理解. 然后,这是线段树裸题,而且是最简单的区间增加与查询,我参考了ACdreamer的模板,在此基础上自己用宏定义来精简了一下代码: 1 #include<cstdio> 2 typedef long long LL; 3 #define root int rt, int l, int r 4 #define lson rt*2, l, mid 5 #define

[ACM] Color the ball [线段树水题][数组开大]

Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N).  当N

HDU 4893 线段树裸题

Wow! Such Sequence! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2512    Accepted Submission(s): 751 Problem Description Recently, Doge got a funny birthday present from his new friend, Pro

HDU 4027 Can you answer these queries? 线段树裸题

题意: 给定2个操作 0.把区间的每个数sqrt 2.求和 因为每个数的sqrt次数很少,所以直接更新到底,用个标记表示是否更新完全(即区间内的数字只有0,1就不用再更新了) #include<stdio.h> #include<iostream> #include<algorithm> #include<vector> #include<cmath> #include<queue> #include<set> #incl

[POJ2104] 区间第k大数 [区间第k大数,可持久化线段树模板题]

可持久化线段树模板题. #include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <vector> using namespace std; int n,q,tot,a[110000]; in

poj 2182 Lost Cows(线段树经典题)

题目链接:http://poj.org/problem?id=2182 Lost Cows Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9152   Accepted: 5879 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular display of poor judgment, th

LA 2191电位计(线段树模板题)

线段树模板题,没啥好说的.....注意输出是case之间空一行就行.........之前一直没注意,一直wa 代码如下: #include<cstdio> #include<cstring> #include<cmath> #include<cstdlib> #include<iostream> #include<algorithm> #include<vector> #include<map> #includ

Codeforces Round #393 (Div. 2) (8VC Venture Cup 2017 - Final Round Div. 2 Edition) E - Nikita and stack 线段树好题

http://codeforces.com/contest/760/problem/E 题目大意:现在对栈有m个操作,但是顺序是乱的,现在每输入一个操作要求你输出当前的栈顶, 注意,已有操作要按它们的时间顺序进行. 思路:线段树好题啊啊,我们把push当成+1, pop当成-1,按操作的位置建立线段树,那么如何 寻找栈顶呢,我们计算每个点的后缀,栈顶就是下标最大的>0的后缀,我们拿后缀建立线段树, 剩下的就是区间加减法,和求区间最大值啦. #include<bits/stdc++.h>

1270. 数列区间最大值(climits用法+线段树模板题)

题目链接: https://www.acwing.com/problem/content/1272/ 题解: 线段树模板题,单点求和.区间查询都可 AC代码: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <climits> using namespace std; const int N = 1e5+10; int a