
线段树
淡蓝色的狼
这个作者很懒,什么都没留下…
展开
-
hdu1556 Color the ball
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 <=原创 2017-08-07 16:32:19 · 165 阅读 · 0 评论 -
线段树建图+spfa
题意: 就是给了n个点,给了m个加边的关系,有向边,但是加边不一定是u->v,可能是u->[l, r]就是u到[l, r]区间里面的每一个点都加一条边,或者是[l, r] -> u,就是[l, r]区间到u加一条边。然后求单源最短路。 #include<bits/stdc++.h>using namespace std;const int maxn=200...原创 2018-07-31 12:17:17 · 208 阅读 · 0 评论 -
E - 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 some of the cows. To keep things s原创 2017-09-07 17:00:50 · 302 阅读 · 0 评论 -
ZOJ Problem Set - 1610 Count the Colors 线段树
Count the Colors Time Limit: 2 Seconds Memory Limit: 65536 KB Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is原创 2017-09-04 21:55:51 · 237 阅读 · 0 评论 -
L - Mayor's posters POJ - 2528
线段树+离散化处理这里讲一下离散化处理int cnt=1,i;//输入数据 for(i=0;i<2*n;i+=2) { scanf("%d%d",&post[i].x,&post[i+1].x); post[i].id=cnt; post[i+1].id=cnt; cnt+原创 2017-09-04 19:36:08 · 277 阅读 · 0 评论 -
51Nod - 1287 加农炮
1287 加农炮 题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注 一个长度为M的正整数数组A,表示从左向右的地形高度。测试一种加农炮,炮弹平行于地面从左向右飞行,高度为H,如果某处地形的高度大于等于炮弹飞行的高度H(A[i] >= H),炮弹会被挡住并落在i - 1处,则A[i - 1] + 1。如果H <= A[原创 2017-09-04 19:30:51 · 358 阅读 · 0 评论 -
线段树区间查询区间更新
模板#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;#define lson rt<<1,l,mid#define rson rt<<1|1,mid+1,rconst int maxn=100000+100;struct node{ int l原创 2017-08-22 16:52:29 · 220 阅读 · 0 评论 -
Color the ball 此题这个用的是线段树
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 <=原创 2017-08-07 20:54:43 · 214 阅读 · 0 评论 -
敌兵布阵
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所以原创 2017-08-07 20:53:13 · 305 阅读 · 0 评论 -
二维线段树模板
#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define ll o<<1#define rr o<<1|1const int maxn=1200;const int inf=0x3f3f3f3f;const long lo...原创 2018-12-07 20:09:04 · 222 阅读 · 0 评论