线段树
黑码
这个作者很懒,什么都没留下…
展开
-
Poj 3468 线段树的区间更新
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 101266 Accepted: 31599 Case Time Limit: 2000MS DescriptionYou have N integers, A1, A2, … , AN.原创 2016-12-16 20:11:08 · 397 阅读 · 0 评论 -
codeforces 739C 线段树的高级应用
题意,给你一个序列,有q次操作,每次对一个区间进行加值,同时要输出 最长的上升序列/下降序列/先上升再下降序列很明显能想到的是利用线段树维护,有很明显的能想到要维护线段树的每个区间的左边界和右边界的值,并且每个点都有维护四种变化的值,然后就懵逼了。 这时候应该想到的是维护每个区间的左右边界的四种情况进行拼凑来更新 一开始想到的是单峰,对于多峰没想到如何维护,其实也是很简单,有点类似拼图或者插头d原创 2017-11-15 20:04:06 · 811 阅读 · 0 评论 -
线段树判一段里面有几段不同的颜色以及更新操作
代码#include <bits/stdc++.h>using namespace std;const int MAXN =3e5+100;#define L(x) (x<<1)#define R(x) (x<<1|1)int a[MAXN];typedef long long ll;struct node{ int l,r; int num; ll tag,l原创 2017-11-14 18:48:19 · 375 阅读 · 0 评论 -
hdu 1255 矩形面积交
给定平面上若干矩形,求出被这些矩形覆盖过至少两次的区域的面积. Input输入数据的第一行是一个正整数T(1注意:本题的输入数据较多,推荐使用scanf读入数据. Output对于每组测试数据,请计算出被这些矩形覆盖过至少两次的区域的面积.结果保留两位小数. Sample Input251 1 4 21 3 3 72 1.5 5 4.5原创 2017-09-26 01:20:42 · 333 阅读 · 0 评论 -
线段树之扫描线之周长并
题意:给n个矩形,求它们重叠后的周长 思路:用线段树的扫描线从下到上扫一遍,与面积并思想有些相似面积并,下面重边的处理相似,但是周长的并需要求的是竖边的个数然后乘以高度,而面积并求的是底边的长乘以高度,这里我们用了区间合并时的lnum和rnum,具体下面有注释#include <stdio.h> #include <string.h> #include <stdlib.h> #incl原创 2017-09-26 01:02:29 · 615 阅读 · 0 评论 -
hdu 1542 矩形交(线段树)
所谓的离散化,大家可以简单的理解为,将一组很大的数据,浓缩为一组很小的数据,用这组数据来代替原数据的作用, 比如给你1000个数,数的范围为(1,1e18)我们这里就可以用离散化,由于只有1000个数,我们可以用一个数组的下标代表提供的每一数,如果需要这个数据了,由于是下标,可以直接通过下标获得,如此就是离散化。 扫描线的知识提供一个大牛的博客:http://www.cnblogs.com/sc原创 2017-09-26 01:01:25 · 253 阅读 · 0 评论 -
codeforces 339D 简单的线段树操作
Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, …, a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to原创 2017-08-10 00:00:53 · 853 阅读 · 0 评论 -
shuoj 风力检测 线段树
风力观测 发布时间: 2017年7月9日 20:20 最后更新: 2017年7月10日 21:12 时间限制: 1000ms 内存限制: 128M描述 小Y正在观测y地区的风力情况,他在一条直线上依此设定了n个观测点,并观测与直线垂直方向的风力值,风力有时是正向的也有时是反向的,规定正向时的风力值为正数,他发现每次风力值的变化都可以表示为观测点上一条线段[L,R]上的同时增强或者减弱原创 2017-07-12 17:49:52 · 445 阅读 · 0 评论 -
Count the Colors 数颜色 离散化+线段树
Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different colors you can see at last.InputT原创 2017-03-16 16:43:33 · 537 阅读 · 0 评论 -
2017 山理校赛 线段树单点更新+状压
皮卡丘的梦想2 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description一天,一只住在 501 实验室的皮卡丘决定发奋学习,成为像 LeiQ 一样的巨巨,于是他向镇上的贤者金桔请教如何才能进化成一只雷丘。 金桔告诉他需要进化石才能进化,并给了他一个地图,地图上有 n 个小镇,他需要从这些小镇中收原创 2017-06-05 01:11:21 · 358 阅读 · 0 评论 -
dfs序详解
http://cdnnn.07net01.com/2015/08/899785.htmlhttp://blog.csdn.NET/ccsu_001/article/details/47667587 这是我将上面的2篇博客合成的一篇文章,链接如上给定一棵n个节点的树,m次查询,每次查询需要求出某个节点深度为h的所有子节点。对于这个问题如果试图去对每个节点保存所有深度的子节点,在数据大的时候内存会吃不转载 2017-05-19 19:12:07 · 491 阅读 · 0 评论 -
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. Each of the battleships can be marked a value of endu原创 2017-03-16 16:50:10 · 353 阅读 · 0 评论 -
hdu 1754 I hate it (线段树)
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0#include <conio.h>#include原创 2017-03-16 16:33:19 · 290 阅读 · 0 评论 -
poj 2155 二维树状数组 二维线段树
Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the follow原创 2016-12-23 14:59:04 · 356 阅读 · 0 评论 -
Can you answer these queries II 线段树(区间的区间更新)
Being a completist and a simplist, kid Yang Zhe cannot solve but get Wrong Answer from most of the OI problems. And he refuse to write two program of same kind at all. So he always failes in contests.W原创 2017-03-13 20:49:52 · 553 阅读 · 0 评论 -
Archery Tournament Gym - 101630A 线段树
Problem A. Archery Tournament Time limit: 3 seconds You were invited to the annual archery tournament. You are going to compete against the best archers from all of the Northern Eurasia. This year,原创 2017-12-10 10:54:49 · 943 阅读 · 0 评论