线段树
bootdubbo
这个作者很懒,什么都没留下…
展开
-
Yet Another Monster Killing Problem
You play a computer game. In this game, you lead a party of m heroes, and you have to clear a dungeon with n monsters. Each monster is characterized by its power ai. Each hero is characterized by his ...原创 2019-11-14 11:40:21 · 856 阅读 · 0 评论 -
D. Distinct Characters Queries【线段树经典染色问题】【适用于颜色数量少】
You are given a string s consisting of lowercase Latin letters and q queries for this string.Recall that the substring s[l;r] of the string s is the string slsl+1…sr. For example, the substrings of “...原创 2019-11-04 16:22:45 · 244 阅读 · 0 评论 -
小阳的贝壳 【线段树+差分】
题目链接链接:https://ac.nowcoder.com/acm/contest/949/H来源:牛客网题目描述小阳手中一共有 n 个贝壳,每个贝壳都有颜色,且初始第 i 个贝壳的颜色为coli。现在小阳有 3 种操作:1 l r x:给 [l,r] 区间里所有贝壳的颜色值加上 x 。2 l r :询问 [l,r] 区间里所有相邻贝壳 颜色值的差(取绝对值) 的最大值(若 l=r...原创 2019-08-15 11:58:57 · 332 阅读 · 0 评论 -
HDU-6602 Longest Subarray
Problem DescriptionYou are given two integers C,K and an array of N integers a1,a2,…,aN. It is guaranteed that the value of ai is between 1 to C.We define that a continuous subsequence al,al+1,…,ar(...原创 2019-08-23 22:29:30 · 148 阅读 · 0 评论 -
HDU - 6315 天真的操作
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:add l r: add o...原创 2019-08-18 13:55:26 · 96 阅读 · 0 评论 -
HDU - 6406 选苹果
There is an apple tree in front of Taotao’s house. When autumn comes, n apples on the tree ripen, and Taotao will go to pick these apples.When Taotao picks apples, Taotao scans these apples from the ...原创 2019-08-18 14:29:24 · 113 阅读 · 0 评论 -
POJ-2777 Count Color【线段树染色经典问题】
Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.There is a very long board with length L centimeter, L is ...原创 2019-08-27 14:22:26 · 180 阅读 · 1 评论 -
CF91B Queue
题目描述There are n n walruses standing in a queue in an airport. They are numbered starting from the queue’s tail: the 1 1 -st walrus stands at the end of the queue and the n n -th walrus stands at the ...原创 2019-08-27 18:53:19 · 352 阅读 · 0 评论 -
CF853A Planning
outputstandard outputHelen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the ...原创 2019-08-27 21:01:51 · 148 阅读 · 0 评论 -
CodeForces 460C
题意:一个长度为 n 的序列 a ,你有 m 次操作的机会,每次操作是将其中连续的 w 个元素增加 1 。最大化最终序列的最小值。思路:明显二分,可以用线段树维护或差分数组,我把两种写法都发出来吧差分数组简单很多,线段树写法代码又长又臭#include<bits/stdc++.h>using namespace std;#define maxn 1000010struct ...原创 2019-08-28 10:46:52 · 216 阅读 · 1 评论 -
P2894 [USACO08FEB]酒店Hotel
题目描述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 th...原创 2019-08-28 19:53:48 · 241 阅读 · 0 评论 -
P1972 [SDOI2009]HH的项链【查询区间不同的数】
题目描述HH 有一串由各种漂亮的贝壳组成的项链。HH 相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义。HH 不断地收集新的贝壳,因此,他的项链变得越来越长。有一天,他突然提出了一个问题:某一段贝壳中,包含了多少种不同的贝壳?这个问题很难回答……因为项链实在是太长了。于是,他只好求助睿智的你,来解决这个问题。输入格式第一行:一个整数N,表示项链的长度。...原创 2019-08-31 21:07:17 · 189 阅读 · 0 评论 -
Greedy Sequence【线段树】
题意:给出n个整数,构造s1,s2,s3...sns1,s2,s3...sns1,s2,s3...sn,sisisi满足五个条件1、s1[i]=is1[i]=is1[i]=i2、对于1<j<=n对于1<j<=n对于1<j<=n,si[j]<si[j−1]si[j]<si[j-1]si[j]<s...原创 2019-09-01 17:55:19 · 206 阅读 · 0 评论 -
basketball team【网络赛 线段树】
题意:给出n个数,和一个m值,如果某个数大于a[i]+m就会使第i个人生气,求使得第i个人生气的最远的那个人与他的距离#include<bits/stdc++.h>using namespace std;#define maxn 1000010typedef long long ll;struct Tree{ int l,r; ll mx;}tree[maxn<&...原创 2019-09-08 19:13:51 · 270 阅读 · 0 评论 -
HDU - 4747 Mex
Mex is a function on a set of integers, which is universally used for impartial game theorem. For a non-negative integer set S, mex(S) is defined as the least non-negative integer which is not appeare...原创 2019-09-17 19:43:09 · 195 阅读 · 0 评论 -
CodeForces - 777E Hanoi Factory
Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Eg...原创 2019-10-06 22:39:17 · 145 阅读 · 0 评论 -
HDU-6638 Snowy Smile【子矩阵最大和】
Problem DescriptionThere are n pirate chests buried in Byteland, labeled by 1,2,…,n. The i-th chest’s location is (xi,yi), and its value is wi, wi can be negative since the pirate can add some poison...原创 2019-08-15 10:26:03 · 239 阅读 · 0 评论 -
C-sequence【线段树+单调栈】
找出左边第一个比ai小的数的位置li与右边第一个比ai小的数的位置ri#include<bits/stdc++.h>using namespace std;#define maxn 3000010typedef long long ll;ll INF=1e18;struct Tree{ int l,r; ll mi,mx;}tree[maxn<<2];...原创 2019-08-09 13:49:14 · 268 阅读 · 0 评论 -
HDU-1754 I Hate It
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 )...原创 2019-07-13 11:52:05 · 253 阅读 · 1 评论 -
POJ-3468 A Simple Problem with Integers
DescriptionYou 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 as...原创 2019-07-13 12:30:25 · 110 阅读 · 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...原创 2019-07-13 13:37:06 · 128 阅读 · 0 评论 -
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 Pudge w...原创 2019-07-13 13:43:58 · 149 阅读 · 0 评论 -
ZOJ-1610 Count the Colors
Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones.Your task is counting the segments of different colors you can see at last.Input...原创 2019-07-13 13:50:29 · 64 阅读 · 0 评论 -
POJ-3264 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 cows. To keep things ...原创 2019-07-13 13:54:51 · 184 阅读 · 0 评论 -
HDU-4027 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 battleships can be marked a value of end...原创 2019-07-13 13:59:25 · 127 阅读 · 0 评论 -
HDU-1540 Tunnel Warfare
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-07-13 14:10:51 · 66 阅读 · 0 评论 -
POJ-1177 Picture
A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered b...原创 2019-07-13 14:16:38 · 164 阅读 · 0 评论 -
HDU - 3308 LCIS
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].Inpu...原创 2019-08-04 18:41:49 · 164 阅读 · 0 评论 -
HDU - 5493 Queue 【线段树】
N people numbered from 1 to N are waiting in a bank for service. They all stand in a queue, but the queue never moves. It is lunch time now, so they decide to go out and have lunch first. When they ge...原创 2019-08-02 08:16:46 · 133 阅读 · 0 评论 -
CodeForces - 527C 矩形切割
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of en...原创 2019-08-18 15:57:08 · 265 阅读 · 0 评论 -
URAL - 1989 Subpalindromes【线段树+hash】
You have a string and queries of two types:replace i’th character of the string by character a;check if substring sj…sk is a palindrome.InputThe first line contains a string consisting of n small ...原创 2019-08-18 17:43:41 · 136 阅读 · 0 评论 -
SPOJ - GSS1 Can you answer these queries I【区间最大子段和】
You are given a sequence A[1], A[2], …, A[N] . ( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). A query is defined as follows:Query(x,y) = Max { a[i]+a[i+1]+…+a[j] ; x ≤ i ≤ j ≤ y }.Given M queries, your program...原创 2019-08-18 18:27:22 · 173 阅读 · 0 评论 -
HDU - 6301 Distinct Values 【贪心||线段树】
Chiaki has an array of n positive integers. You are told some facts about the array: for every two elements ai and aj in the subarray al…r (l≤i<j≤r), ai≠aj holds.Chiaki would like to find a lexico...原创 2019-08-18 19:36:22 · 128 阅读 · 0 评论 -
HDU-1166 敌兵布阵
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以...原创 2019-07-13 10:56:29 · 67 阅读 · 0 评论