
线段树 | 树状数组 | RMQ
文章平均质量分 71
YOONGI
这个作者很懒,什么都没留下…
展开
-
NYOJ 士兵杀敌(一)(树状数组 | 线段树 | zkw线段树)
士兵杀敌(一)题目描述南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军现在想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。注意,南将军可能会问很多次问题。输入只有一组测试数据 第一行是两个整数N,M,其中N表示士兵的个数(1<N<1000000),M表示南将军询问的次数(1<M<...原创 2018-05-03 19:47:48 · 165 阅读 · 0 评论 -
HDU - 1540 Tunnel Warfare (线段树 单点更新 区间最值)
Tunnel WarfareDuring the War of Resistance Against Japan, tunnel warfare was carried out extensively in the vast areas of north China Plain. Generally speaking, villages connected by tunnels lay ...原创 2019-08-06 16:09:26 · 102 阅读 · 0 评论 -
HDU - 6315 Naive Operations (线段树 区间查询 区间修改)
Naive OperationsIn a galaxy far, far away, there are two integer sequence a and b of length n.b is a static permutation of 1 to n. Initially a is filled with zeroes.There are two kind of operati...原创 2019-08-08 09:30:49 · 135 阅读 · 0 评论 -
LibreOJ #144. DFS 序 1 (线段树 | 树状数组 | zkw线段树)
题目描述这是一道模板题。给一棵有根树,这棵树由编号为1...N的N个结点组成。根结点的编号为R。每个结点都有一个权值,结点i的权值为Vi。接下来有组操作,操作分为两类:1 a x,表示将结点a的权值增加x; 2 a,表示求结点a的子树上所有结点的权值之和。输入第一行有三个整数N,M和R。第二行有N个整数,第i个整数表示Vi。在接下来的N-1行中,每行...原创 2019-04-29 11:27:13 · 655 阅读 · 0 评论 -
士兵杀敌(三) (RMQ | zkw线段树)
士兵杀敌(三)题目描述:南将军统率着N个士兵,士兵分别编号为1~N,南将军经常爱拿某一段编号内杀敌数最高的人与杀敌数最低的人进行比较,计算出两个人的杀敌数差值,用这种方法一方面能鼓舞杀敌数高的人,另一方面也算是批评杀敌数低的人,起到了很好的效果。所以,南将军经常问军师小工第i号士兵到第j号士兵中,杀敌数最高的人与杀敌数最低的人之间军功差值是多少。现在,请你写一个程序,帮小工回答南将...原创 2019-04-23 10:59:00 · 134 阅读 · 0 评论 -
HDU - 5542 The Battle of Chibi (DP + 离散化+树状数组)
The Battle of ChibiCao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao's army....原创 2019-04-17 10:41:18 · 178 阅读 · 0 评论 -
Can you answer these queries? (线段树)
Can you answer these queries? 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 battle...原创 2018-09-27 21:04:54 · 650 阅读 · 0 评论 -
Balanced Lineup (线段树)
Balanced Lineup 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 c...原创 2018-09-23 16:56:24 · 343 阅读 · 0 评论 -
Just a Hook (线段树)
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 leng...原创 2018-09-23 16:04:58 · 388 阅读 · 0 评论 -
A Simple Problem with Integers POJ - 3468(线段树)
A Simple Problem with IntegersYou 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 inter...原创 2018-09-23 11:04:10 · 148 阅读 · 0 评论 -
I Hate It HDU - 1754 (线段树)
I Hate It很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,...原创 2018-09-23 11:01:24 · 164 阅读 · 0 评论 -
敌兵布阵 (树状数组 | 线段树)
敌兵布阵 C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究...原创 2018-05-03 20:04:45 · 167 阅读 · 0 评论 -
NYOJ 士兵杀敌(二)(树状数组 | 线段树 | zkw线段树 区间求和 单点更新)
士兵杀敌(二)题目描述:南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。输入描述:只有一组测试数据 第一行是两个整数N,M,其中N表示士兵的个数(1<N...原创 2018-05-03 19:54:44 · 149 阅读 · 0 评论 -
HDU - 3974 Assign the task (DFS +线段树)
Assign the taskThere is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate b...原创 2019-08-06 17:29:49 · 148 阅读 · 0 评论