
线段树+树状数组+RMQ
creator平
期望破茧成蝶时的飞翔,向往突破蝉蛹后的鸣叫。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU - 1166——敌兵布阵 (线段树单点更改)
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所...原创 2018-05-25 11:43:44 · 269 阅读 · 0 评论 -
UVA - 11992——Fast Matrix Operations(线段树)
题目链接:https://cn.vjudge.net/problem/UVA-11992思路:把二维当成一维,每次查询或者操作x1,y1,x2,y3区域的时候都分成处理x2-x1+1个小段,每一段处理y1~y2这个区间。#include<string.h>#include<stdio.h>#include<algorithm>using name...原创 2019-03-21 21:06:18 · 178 阅读 · 0 评论 -
HihoCoder - 1710——等差子数列 (RMQ)
voj题目链接:https://cn.vjudge.net/problem/HihoCoder-1710思路:与UVA - 11235 类型相同,之前写过,思路也一样之前写的 UVa 11235:https://blog.youkuaiyun.com/weixin_41380961/article/details/88670210#include<algorithm>#inclu...原创 2019-04-05 10:45:03 · 181 阅读 · 0 评论 -
FZU - 1921——栀子花开(线段树)
voj题目链接:https://cn.vjudge.net/contest/292206#problem/HFZU题目链接:https://cn.vjudge.net/contest/292206#problem线段树模板题:线段树的单点修改#include<algorithm>#include<stdio.h>#include<string.h&g...原创 2019-04-03 13:07:04 · 169 阅读 · 0 评论 -
线段树套无旋streap树(模板)
题目链接:https://www.luogu.org/problemnew/show/P3380感谢:https://blog.youkuaiyun.com/chenxiaoran666/article/details/82949397一个磕了几天的模板题,一个rand()的打错就T到疯。MMP。自己写的一个板子。#include<algorithm>#include<...原创 2019-05-01 17:25:13 · 197 阅读 · 0 评论 -
HUSTOJ 1009: 第一个简单题(DFS序+树状数组)
题目链接:http://129.211.20.246/problem.php?id=1009思路:DFS序先处理,然后树状数组维护。#include<algorithm>#include<string.h>#include<stdio.h>#include<vector>#define ll long longusing name...原创 2019-04-29 09:11:21 · 202 阅读 · 0 评论 -
Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)——D. Restore Permutation(树状数组+二分)
题目链接:http://codeforces.com/contest/1208/problem/D思路:从后往前确定,Sn=1+2.....(Pn)-1,所以可以直接得出最后一个Pn,然后再找Pn-1, 如果Pn-1大于Pn,Sn=1+2+..(Pn-1)-1 如果Pn-1小于Pn,Sn=1+2+...(Pn-1)-1-Pn直接二分枚举Pi,...原创 2019-08-27 17:23:01 · 218 阅读 · 0 评论 -
P1816 忠诚(RMQ模板)
题目链接:https://www.luogu.org/problem/P1816#include<bits/stdc++.h>using namespace std;int n,m;int dp[10000050][32],A[1000005],ans[1000005];void ST(){ for(int i=1; i<=n; i++) ...原创 2019-09-10 18:15:48 · 205 阅读 · 0 评论 -
洛谷 P3374 【模板】树状数组 1
题目链接:https://www.luogu.org/problem/P3374模板题:/*洛谷 P3374 【模板】树状数组 1n个数,m个查询,a1....an。查询有两个操作操作1: 格式:1 x k 含义:将第x个数加上k操作2: 格式:2 x y 含义:输出区间[x,y]内每个数的和5 51 5 4 2 31 1 32 2 51 3 -11 4 22 1 ...原创 2019-09-11 19:58:17 · 143 阅读 · 0 评论 -
UVA - 11235——Frequent values(RMQ)
题目链接:https://cn.vjudge.net/problem/UVA-11235思路:找出每个位置的数出现的次数,用time[i]表示i位置上的数的出现次数,lef[i]表示最左边与i位置相同的的数的位置,righ表示最右边与i位置相同数的位置。用RMQ处理time数组。则区间【L,R】中出现最多数的次数为下面三个数的最大值1. righ[L]-L+12. R-lef[R]...原创 2019-03-19 19:15:02 · 195 阅读 · 0 评论 -
UVALive - 4329——Ping pong (树状数组)
题目链接:https://cn.vjudge.net/problem/UVALive-4329题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2330思路:找出i位置前面技能值小于a[i]的人的个数c...原创 2019-03-19 15:40:39 · 151 阅读 · 0 评论 -
HDU - 2795 - Billboard
At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest p...原创 2018-07-14 11:03:14 · 214 阅读 · 0 评论 -
HDU - 1754 ——I Hate It (线段树的单点最大值)
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=20...原创 2018-05-26 10:51:34 · 367 阅读 · 0 评论 -
POJ - 3468——A Simple Problem with Integers (线段树区间查询/修改)
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 number in a given interval. The other is to ask for the ...原创 2018-05-26 19:24:40 · 138 阅读 · 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 d...原创 2018-05-29 17:32:56 · 474 阅读 · 0 评论 -
nyoj-116-士兵杀敌(二)
题目描述: 南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。 ...原创 2018-07-10 14:58:51 · 136 阅读 · 0 评论 -
树状数组
问题引入:http://nyoj.top/problem/116https://www.cnblogs.com/Howe-Young/p/4009223.html?ADUIN=1466989448&ADSESSION=1413411257&ADTAG=CLIENT.QQ.5359_.0&ADPUBNO=26397树状数组详解: https://www.c...原创 2018-07-10 17:23:34 · 163 阅读 · 0 评论 -
nyoj-119-士兵杀敌(三)
题目描述: 南将军统率着N个士兵,士兵分别编号为1~N,南将军经常爱拿某一段编号内杀敌数最高的人与杀敌数最低的人进行比较,计算出两个人的杀敌数差值,用这种方法一方面能鼓舞杀敌数高的人,另一方面也算是批评杀敌数低的人,起到了很好的效果。所以,南将军经常问军师小工第i号士兵到第j号士兵...原创 2018-07-12 09:00:49 · 132 阅读 · 0 评论 -
POJ - 3468-A Simple Problem with Integers (树状数组)
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 number in a given interval. The other is to ask for the ...原创 2018-07-13 11:25:46 · 265 阅读 · 4 评论 -
HDU - 1698 - 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. Now Pu...原创 2018-07-13 18:01:06 · 158 阅读 · 0 评论 -
codeforces 915E - Physical Education Lessons(线段树动态开点板子题)
题意:从现在到学期结束还有 n 天(从 1 到 n 编号),他们一开始都是1。接下来学校的工作人员会依次发出 q 个指令,每个指令可以用三个参数 l,r,k 描述:如果 k=1那么从 l 到 r (包含端点)的所有日子都变成0。如果 k=2那么从 l 到 r (包含端点)的所有日子都变成1。输出 q 行,第 i 行表示第 i 个指令被下发后1~n的和。思路:线段树动态开点:...原创 2019-09-18 19:56:21 · 136 阅读 · 0 评论