
线段树
文章平均质量分 83
RJ28
小学生
展开
-
Codeforces Round #337 (Div. 2) D. Vika and Segments
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVika has an infinite sheet of squared paper. Initially all squares are w原创 2016-03-22 17:12:08 · 441 阅读 · 0 评论 -
Codeforces Round #429 (Div. 1) D. Destiny(主席树)
D. Destinytime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOnce, Leha found in the left pocket an array c原创 2017-08-25 17:08:05 · 478 阅读 · 0 评论 -
Hdu-6133 Army Formations(线段树合并)
Though being cruel and merciless in the battlefields, the total obedience to the command hierarchy makes message delivering between Stormtroopers quite inefficient, which finally caused the escape of原创 2017-08-19 20:31:50 · 751 阅读 · 4 评论 -
Codeforces Round #416 (Div. 2) E. Vladik and Entertaining Flags(线段树+并查集)
In his spare time Vladik estimates beauty of the flags.Every flag could be represented as the matrix n × m which consists of positive integers.Let's define the beauty of the flag as number of原创 2017-07-17 22:26:57 · 366 阅读 · 0 评论 -
Codeforces Round #397 F. Souvenirs(线段树,离线)
Artsem is on vacation and wants to buy souvenirs for his two teammates. There are n souvenir shops along the street. In i-th shop Artsem can buy one souvenir for ai dollars, and he cannot buy more原创 2017-02-23 15:58:05 · 437 阅读 · 0 评论 -
Codeforces Round #381 (Div. 1) C. Alyona and towers(线段树)
Alyona has built n towers by putting small cubes some on the top of others. Each cube has size 1 × 1 × 1. A tower is a non-zero amount of cubes standing on the top of each other. The towers are next原创 2016-12-07 22:40:31 · 670 阅读 · 0 评论 -
Hdu-4348 To the moon(可持久化线段树)
DescriptionBackground To The Moon is a independent game released in November 2011, it is a role-playing adventure game powered by RPG Maker.The premise of To The Moon is based around a techn原创 2016-10-08 15:19:33 · 557 阅读 · 0 评论 -
Hdu-5919 Sequence II(主席树在线求区间不同数)
DescriptionMr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯,an There are m queries. In the i-th query, you are given two integers li and ri. Consider the subse原创 2016-10-05 23:32:52 · 714 阅读 · 0 评论 -
带修改的主席树
时间空间复杂度均为n*log^2,时间还好,空间简直爆炸。。。#include #include #include #include #include #include #include #include #include #include #include #include #define MOD 1000000007#define N 100005usi原创 2016-10-05 18:16:32 · 1502 阅读 · 3 评论 -
Hdu-2665 Kth number(主席树)
Problem DescriptionGive you a sequence and ask you the kth big number of a inteval. InputThe first line is the number of the test cases. For each test case, the first line contain原创 2016-10-05 16:05:41 · 272 阅读 · 0 评论 -
Codeforces Round 718C (矩阵线段树)
Sasha has an array of integers a1, a2, ..., an. You have to performm queries. There might be queries of two types:1 l r x — increase all integers on the segment froml to r by valuesx; 2原创 2016-10-05 13:04:26 · 361 阅读 · 0 评论 -
Hdu-5438 Boring counting(可持久化线段树)
DescriptionIn this problem we consider a rooted tree with N vertices. The vertices are numbered from 1 to N, and vertex 1 represents the root. There are integer weights on each vectice. Your task原创 2016-10-16 18:16:32 · 331 阅读 · 0 评论 -
Bzoj-3242 快餐店(环套树)
Description小T打算在城市C开设一家外送快餐店。送餐到某一个地点的时间与外卖店到该地点之间最短路径长度是成正比的,小T希望快餐店的地址选在离最远的顾客距离最近的地方。 快餐店的顾客分布在城市C的N 个建筑中,这N 个建筑通过恰好N 条双向道路连接起来,不存在任何两条道路连接了相同的两个建筑。任意两个建筑之间至少存在一条由双向道路连接而成的路径。小T的快餐店可以开设在任一建筑中,也原创 2016-11-04 21:15:01 · 458 阅读 · 0 评论 -
Hdu-5893 List wants to travel(树链剖分)
Problem DescriptionA boy named List who is perfect in English. Now he wants to travel and he is making a plan. But the cost of living in same citie always changes. Now he wants to know how many diff原创 2016-09-18 23:11:53 · 398 阅读 · 0 评论 -
Hdu-5828 Rikka with Sequence(线段树)
Problem DescriptionAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:Yuta has an array A with n number原创 2016-08-11 23:14:54 · 390 阅读 · 0 评论 -
Spoj 375 QTREE(树链剖分)
DescriptionYou are given a tree (an acyclic undirected connected graph) with N nodes, and edges numbered 1, 2, 3...N-1.We will ask you to perfrom some instructions of the following form:原创 2016-08-22 23:56:58 · 374 阅读 · 0 评论 -
DOJ - 1005 City Horizon (线段树扫面线)
问题描述Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city horizon and observe the beautiful silhouettes formed by the rectangular buildings.The entire原创 2016-05-14 15:40:43 · 379 阅读 · 0 评论 -
BSUIR Open 2017 Finals Financial Reports(线段树)
题意:10^5的数列,让你交换两个数,使得交换后的数列的连续区间最大和最大。分析:我们假设最优解是交换u 和 v,u >= v,那么交换后的最优解应该是以交换后u向左右两端分别扩展的一段区间,和u之前位置异侧的最大扩展值可以O(n)的DP预处理出来,然后我们考虑和u之前位置(也就是v现在的位置)同侧的最大扩展区间,可以证明在原数列中u一定是这个扩展区间终点再往后/前的最大值,所以我们考原创 2017-09-23 00:34:13 · 388 阅读 · 0 评论