
线段树
几许情愁
这个作者很懒,什么都没留下…
展开
-
(线段树单点更新)Can you answer these queries? 几许情愁
Problem DescriptionA 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 ma...原创 2018-05-18 20:52:14 · 144 阅读 · 0 评论 -
平衡树模板
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=1e9+7; const int N=1e6+10; int ch[N][2]; //ch[][0] 表示左儿子 ch[][1] 表示右儿子 int f[N]; //节点的父亲节点 int sz[N]; ...原创 2019-04-20 21:19:58 · 357 阅读 · 0 评论 -
数列分块入门3
#include<stdio.h> #include<string.h> #include<string> #include<iostream> #include<algorithm> #include<queue> #include<math.h> #include<map> #in原创 2018-09-28 21:14:17 · 252 阅读 · 0 评论 -
数列分块入门2
给出一个长为n的数列,以及n个操作,操作涉及区间加法,询问区间内小于某个值x的元素个数。 /*对于在一个区间内小于c的元素的个数问题,用分块方法求解, 我们可以进行这样的预处理:把每个块的元素进行排序: 这样找的话,对于两端没有在块里的元素暴力计算,块内的只需要二分, 可以引用vector,记录每个块排序过后的序列 */ #include<stdio.h> #inclu...原创 2018-09-28 19:22:11 · 292 阅读 · 0 评论 -
【hdu 1540】Tunnel Warfare 线段树
Problem Description 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 tun...原创 2018-09-24 19:03:46 · 111 阅读 · 0 评论 -
A Simple Problem with Integers 【线段树区间更新 区间查询】
POJ 3468 题意就不说了,之间看代码; 代码是对的,如果大佬觉得注释有问题可以说,会仔细更改原创 2018-09-18 20:28:34 · 190 阅读 · 0 评论 -
Balanced Lineup 【线段树】
Description 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...原创 2018-09-23 15:28:44 · 237 阅读 · 0 评论 -
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. ...原创 2018-09-23 15:24:20 · 369 阅读 · 0 评论 -
I Hate it 【线段树单点更新】
Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个...原创 2018-09-18 19:57:08 · 104 阅读 · 0 评论 -
【线段树+离散化】Mayor's posters 几许情愁
Mayor's postersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 74126 Accepted: 21384DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campa...原创 2018-05-28 13:26:28 · 185 阅读 · 0 评论 -
2019牛客多校第四场 C squence 【单调栈+线段树】
题目链接:https://ac.nowcoder.com/acm/contest/884/C /* 思路:构造一个单调减栈(栈里元素下标增大值增大),把序列 A 添加进去,如果当前 A[i] 比栈头元素小, 将栈头元素弹出,此时以弹出元素为最小的区间就是此时栈头元素的下标和当前 A[i] 下标即i,然后用线段 树来求出这个区间里 B 的前缀和最大的差值。 具体为:假设以当前A[i]为最小的区间...原创 2019-07-30 09:29:07 · 236 阅读 · 0 评论