
线段树
junior19
abcde
展开
-
HDU1394:Minimum Inversion Number(线段树)
Minimum Inversion NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19405 Accepted Submission(s): 11684Problem Description原创 2017-03-08 14:05:11 · 246 阅读 · 0 评论 -
CodeChef:Chef and Subarray Queries(线段树)
思路:求值在[L,R]之间的题目,往往转化成求[1,R]-[1,L-1],然后这题用线段树处理,每个节点计算当前区间的答案,主要思考合并操作的写法,代码思路还是比较简单的。# include # include # define lson l,m,id<<1# define rson m+1, r, id<<1|1using namespace std;typedef long lo原创 2017-11-22 19:27:10 · 261 阅读 · 0 评论 -
CodeChef:L-R queries(线段树 & set)
Chef has an array A of size N. His friend Chuwi playing with this array in a next way: he chooses a continuous subarray A[L..R] and finds the maximum of (A[M] - A[L]) * (A[R] - A[M]) ove原创 2017-11-28 11:34:33 · 271 阅读 · 0 评论 -
CodeChef:Minimum SubArray(线段树最值)
You are given a sequence of n integers a1, a2, ..., an and an integer d.Find the length of the shortest non-empty contiguous subsequence with sum of elements at least d. Formally, you should fin原创 2017-12-25 11:28:02 · 341 阅读 · 0 评论 -
BZOJ2212:Tree Rotations(线段树合并 & 逆序数^)
现在有一棵二叉树,所有非叶子节点都有两个孩子。在每个叶子节点上有一个权值(有n个叶子节点,满足这些权值为1..n的一个排列)。可以任意交换每个非叶子节点的左右孩子。要求进行一系列交换,使得最终所有叶子节点的权值按照遍历序写出来,逆序对个数最少。Input第一行n下面每行,一个数x如果x==0,表示这个节点非叶子节点,递归地向下读入其左孩子和右孩子的信息,如果x!原创 2018-01-21 19:09:53 · 301 阅读 · 0 评论 -
ZOJ4009:And Another Data Structure Problem(线段树区间更新)
And Another Data Structure ProblemTime Limit: 7 Seconds Memory Limit: 262144 KBGiven integers . There are 2 types of operations:1 l r: Change to ;2 l r: Query the value of modulo 99971.For eac...原创 2018-03-21 12:45:28 · 235 阅读 · 0 评论 -
ZOJ3998:Yet Another Data Structure Problem(线段树区间更新)
Given integers . There are 3 types of operations:1 l r v: Multiply by ;2 l r k: Change each element in to ;3 l r: Query the multiplication of modulo 1,000,000,007.For each query, please output the...原创 2018-03-21 22:36:58 · 467 阅读 · 0 评论 -
Wannafly挑战赛10:小H的询问(线段树合并)
小H给你一个数组{a},要求支持以下两种操作: 1. 0 l r(1<=l<=r<=n),询问区间[l,r]中权值和最大的有效子区间的权值和,一个子区间被认为是有效的当且仅当这个子区间中没有两个相邻的偶数或者奇数。 2. 1 x v(1<=x<=n,-109<=v<=109),将a[x]的值修改为v。 输入描述:第一行读入两个正整数n,m(...原创 2018-04-10 20:55:47 · 348 阅读 · 0 评论 -
HDU6315:Naive Operations(线段树区间更新)
In 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 operations: 1. add l r: ...原创 2018-07-25 23:18:41 · 228 阅读 · 0 评论 -
NOWCODER:整数序列(线段树区间更新)
链接:https://www.nowcoder.com/acm/contest/160/D来源:牛客网 题目描述给出一个长度为n的整数序列a1,a2,...,an,进行m次操作,操作分为两类。操作1:给出l,r,v,将al,al+1,...,ar分别加上v;操作2:给出l,r,询问输入描述:第一行一个整数n接下来一行n个整数表示a1,a2,...,an接下来一行一个整...原创 2018-08-21 00:56:51 · 272 阅读 · 0 评论 -
POJ1195:Mobile phones(二维BIT 或 CDQ分治 或 二维线段树)
Mobile phonesTime Limit: 5000MS Memory Limit: 65536K Total Submissions: 22311 Accepted: 10372 DescriptionSuppose that the fourth generation mobile phone base stations in the Ta...原创 2018-08-24 17:00:50 · 192 阅读 · 0 评论 -
ARC085:F - NRE(线段树 & dp)^
F - NRETime limit : 3sec / Memory limit : 256MBScore : 1000 pointsProblem StatementYou are given a sequence a={a1,…,aN} with all zeros, and a sequence b={b1,…,bN} consisting of原创 2017-11-20 21:15:38 · 628 阅读 · 0 评论 -
CF840D:Destiny(线段树)
D. Destinytime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOnce, Leha found in the left pocket an array c原创 2017-09-01 13:09:33 · 684 阅读 · 0 评论 -
HDU2795:Billboard(线段树)
BillboardTime Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20957 Accepted Submission(s): 8670Problem DescriptionAt the entranc原创 2017-03-08 15:15:52 · 241 阅读 · 0 评论 -
POJ2828:Buy Tickets(线段树)
Buy TicketsTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 19585 Accepted: 9691DescriptionRailway tickets were difficult to buy around the Lunar New Y原创 2017-03-08 22:24:21 · 225 阅读 · 0 评论 -
POJ2866:Who Gets the Most Candies?(线段树 + 反素数 + 约瑟夫环)
reference:http://blog.youkuaiyun.com/acdreamers/article/details/8577673Who Gets the Most Candies?Time Limit: 5000MS Memory Limit: 131072KTotal Submissions: 14195 Accepted: 4489原创 2017-03-09 20:44:02 · 307 阅读 · 0 评论 -
HDU1166:敌兵布阵(线段树)
敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 83744 Accepted Submission(s): 35376Problem DescriptionC国的死对头A国这段时间正在进行军事演原创 2017-03-07 22:04:51 · 209 阅读 · 0 评论 -
POJ3468:A Simple Problem with Integers(线段树区间更新)
A Simple Problem with IntegersTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 106215 Accepted: 33148Case Time Limit: 2000MSDescriptionYou have原创 2017-03-28 21:30:07 · 265 阅读 · 0 评论 -
CF91B:Queue(线段树,区间最值)
B. Queuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n walruses standing in a queue in an air原创 2017-03-30 17:18:59 · 418 阅读 · 0 评论 -
CFgym:Ex Machina(交互 & 线段树区间最值)
M. Ex Machinatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpecial agent Adam is hacking a calculator of原创 2017-04-28 18:18:06 · 312 阅读 · 0 评论 -
HDU5692:Snacks(DFS序 & 线段树区间更新)
SnacksTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2796 Accepted Submission(s): 646Problem Description百度科技园内有n个零食机,零食机之间通原创 2017-07-17 20:07:13 · 246 阅读 · 0 评论 -
CF445E:DZY Loves Colors(线段树区间更新)^
E. DZY Loves Colorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDZY loves colors, and he enjoys paintin原创 2017-08-09 20:13:05 · 242 阅读 · 0 评论 -
CF242:XOR on Segment(线段树区间更新 & 二进制)
E. XOR on Segmenttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got an array a, consisting of n in原创 2017-08-09 22:03:58 · 452 阅读 · 0 评论 -
洛谷:P哥的桶(线段树 + 线性基)
题目背景P哥在IOI取得了金牌,现在他开始找女朋友了!题目描述P哥现在有nn个桶,他们排成了一排,这些桶可以装下任意多个女朋友。每个女朋友有一个固定的颜值P哥时不时地会找新女朋友,并把新找的女朋友丢进某个桶里面。我们用1\;k\;x1kx来表示P哥找了一个颜值为xx的女朋友,并且丢进了kk号桶里面P哥每天晚上需要在特定的桶里面找一些女朋友观赏。我们用2\;l\;r2lr来表示P...原创 2018-09-02 23:30:45 · 717 阅读 · 0 评论