
线段树
隔阂0323
加速零到一百公里
展开
-
A - Ultra-QuickSort POJ - 2299 线段树
DescriptionIn this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seque...原创 2019-07-08 14:54:01 · 214 阅读 · 0 评论 -
Super Mario HDU - 4417 主席树/线段树离线处理
Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to...原创 2019-08-09 14:32:58 · 140 阅读 · 0 评论 -
Sasha and Array CodeForces - 719E 线段树维护矩阵+矩阵快速幂
Sasha has an array of integersa1, a2, ..., an. You have to performmqueries. There might be queries of two types:1 l r x— increase all integers on the segment fromltorby valuesx; 2 l r— fi...原创 2019-08-09 15:29:24 · 268 阅读 · 0 评论 -
GCD HDU - 5726 线段树+数学
Give you a sequence ofN(N≤100,000)N(N≤100,000)integers :a1,...,an(0<ai≤1000,000,000)a1,...,an(0<ai≤1000,000,000). There areQ(Q≤100,000)Q(Q≤100,000)queries. For each queryl,rl,ryou have to...原创 2019-08-10 11:25:18 · 259 阅读 · 0 评论 -
Longest Subarray HDU - 6602 线段树+思维
You are given two integersC,KC,Kand an array ofNNintegersa1,a2,...,aNa1,a2,...,aN. It is guaranteed that the value ofaiaiis between11toCC.We define that a continuous subsequenceal,al+1,.....原创 2019-08-11 11:39:30 · 163 阅读 · 0 评论 -
Petya and Array CodeForces - 1042D 线段树+思维
Petya has an arrayaaconsisting ofnnintegers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty ...原创 2019-08-15 11:04:11 · 316 阅读 · 0 评论 -
Snowy Smile HDU - 6638 利用线段树区间合并 求最大子段和
Snowy SmileTime Limit: 4000/4000 MS (Java/Others)Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 2429Accepted Submission(s): 774Problem DescriptionThere arenpirate c...原创 2019-08-11 16:03:28 · 269 阅读 · 0 评论 -
GCD HDU - 5930
Mr. Frog likes generating numbers! He can generate many numbers from a sequence.For a given sequencea1,a2,⋯,ana1,a2,⋯,anMr. Frog can choose two numbers l and r (1≤l≤r≤n1≤l≤r≤n) and calculate the g...原创 2019-08-12 15:14:36 · 233 阅读 · 0 评论 -
Different GCD Subarray Query HDU - 5869 线段树+离线处理
This is a simple problem. The teacher gives Bob a list of problems about GCD (Greatest Common Divisor). After studying some of them, Bob thinks that GCD is so interesting. One day, he comes up with a ...原创 2019-08-12 15:28:34 · 196 阅读 · 0 评论 -
No Pain No Game HDU - 4630 线段树+离线处理
Life is a game,and you lose it,so you suicide.But you can not kill yourself before you solve this problem:Given you a sequence of number a1, a2, ..., an.They are also a permutation of 1...n.Y...原创 2019-08-12 15:39:41 · 198 阅读 · 0 评论 -
HDU 3333 Turing Tree 主席树/线段树离线处理
After inventing Turing Tree, 3xian always felt boring when solving problems about intervals, because Turing Tree could easily have the solution. As well, wily 3xian made lots of new problems about int...原创 2019-08-09 14:18:47 · 272 阅读 · 0 评论 -
D-query SPOJ - DQUERY 主席树/线段树离线处理
Given a sequence of n numbers a1, a2, ..., anand a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the ...原创 2019-08-09 14:05:11 · 240 阅读 · 0 评论 -
牛客 A-Laptop 线段树
题目描述FST是一名可怜的小朋友,他很强,但是经常fst,所以rating一直低迷。但是重点在于,他非常适合ACM!并在最近的区域赛中获得了不错的成绩。拿到奖金后FST决定买一台新笔记本,但是FST发现,在价格能承受的范围内,笔记本的内存和速度是不可兼得的。可是,有一些笔记本是被另外一些“完虐”的,也就是内存和速度都不高于另外某一个笔记本,现在FST想统计一下有多少笔记本被“完虐”。...原创 2019-07-08 15:14:00 · 361 阅读 · 0 评论 -
Infinite Inversions CodeForces - 540E 线段树+离散化
There is an infinite sequence consisting of all positive integers in the increasing order:p = {1, 2, 3, ...}. We performednswapoperations with this sequence. Aswap(a, b)is an operation of swappi...原创 2019-07-08 16:12:51 · 182 阅读 · 0 评论 -
Mayor's posters POJ - 2528 线段树+离散化
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...原创 2019-07-08 17:19:23 · 140 阅读 · 0 评论 -
Physical Education Lessons CodeForces - 915E 线段树+离散化
This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend phys...原创 2019-07-09 09:44:00 · 201 阅读 · 0 评论 -
Sign on Fence CodeForces - 484E 可持久化线段树区间合并+二分
Bizon the Champion has recently finished painting his wood fence. The fence consists of a sequence ofnpanels of1meter width and of arbitrary height. Thei-th panel's height ishimeters. The adjac...原创 2019-08-03 20:08:00 · 350 阅读 · 0 评论 -
2019牛客暑期多校训练营(第七场) 权值线段树或主席树
链接:https://ac.nowcoder.com/acm/contest/887/C题目描述The Wow village is often hit by wind and sand,the sandstorm seriously hindered the economic development of the Wow village.There is a forest in fr...原创 2019-08-09 11:02:37 · 158 阅读 · 0 评论 -
Tunnel Warfare HDU - 1540 线段树区间合并
During 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 in a line. Except t...原创 2019-08-09 13:20:41 · 133 阅读 · 0 评论 -
Hotel POJ - 3667 线段树区间合并
The cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bessie, ever the competent travel agent, has named the Bul...原创 2019-08-09 13:41:57 · 140 阅读 · 0 评论 -
LCIS HDU - 3308 线段树区间合并
Given n integers.You have two operations:U A B: replace the Ath number by B. (index counting from 0)Q A B: output the length of the longest consecutive increasing subsequence (LCIS) in [a, b]....原创 2019-08-09 13:47:16 · 194 阅读 · 0 评论 -
小Z的加油店 HYSBZ - 5028 线段树+数学
小Z经营一家加油店。小Z加油的方式非常奇怪。他有一排瓶子,每个瓶子有一个容量vi。每次别人来加油,他会让别人选连续一段的瓶子。他可以用这些瓶子装汽油,但他只有三种操作:1.把一个瓶子完全加满;2.把一个瓶子完全倒空;3.把一个瓶子里的汽油倒进另一个瓶子,直到倒出瓶子空了或者倒进的瓶子满了。当然,为了回馈用户,小Z会时不时选择连续一段瓶子,给每个瓶子容积都增加x。为了尽可能给...原创 2019-08-12 16:00:53 · 215 阅读 · 0 评论