线段树
永恒—
反复与坚持之后,柔水终成雕刀
展开
-
Vases and Flowers HDU - 4614(思维 二分 线段树)
题目 Alice有N个花瓶(标号为0~ N-1)。当她收到一些花时,她会随机的选择一个瓶子A,从它开始遍历A,A+1, A+2, …, N-1号瓶子,遇到空瓶子就放一朵花进去,直到花朵放完或没有瓶子,剩下的花将被丢弃。有时,她也会清理标号从A到B的花瓶(A <= B).花瓶里的花会被丢弃。 Input 第一行一个整数T,表示数据组数。 每组数据,第一行一个整数N(1 < N < ...原创 2020-02-03 17:36:40 · 159 阅读 · 0 评论 -
Transformation HDU - 4578(区间值多重复值 线段树 lazy)
题目 Yuanfang is puzzled with the question below: There are n integers, a 1, a 2, …, a n. The initial values of them are 0. There are four kinds of operations. Operation 1: Add c to each number between ...原创 2020-01-27 15:30:14 · 121 阅读 · 0 评论 -
Assign the task HDU - 3974(dfs序+线段树)
题目 There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the leader of whole company).If you are the immediate boss of someone,th...原创 2020-01-23 18:43:54 · 101 阅读 · 0 评论 -
Tunnel Warfare HDU - 1540(线段树做法 (修改查询区间最大值最小值)or stl做法)
题目 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. Excep...原创 2020-01-21 16:19:54 · 117 阅读 · 0 评论 -
线段树区间求和、点更新,区间求最大值、点更新与区间染色、离散化、lazy
线段树区间求和, 点更新 void build(int l, int r, int ret){ int m; if(l == r){ scanf("%d", &sum[ret]); return ; } m = (l+r)>>1; build(l, m, ret*2); build(m+1, r, ...原创 2019-07-14 16:34:54 · 283 阅读 · 0 评论 -
HDU - 1698(区间修改,取件查询,lazy区间标记更新)
题意 给你个大区间,区间上初始值皆为1,然后给出一系列修改操作,查询操作。 修改操作可修改区间l~r上的值为k(1,2,3),查询操作问区间 l ~ r上的数值总和为多少。 解释 利用线段树,求和版本,但利用lazy标记,lazy只标记在符合更新的区间内的区间点。然后在query里写在向下更新前,进行pushdown的lazy更新。pushdown中利用lazy得到子节点的lazy值,同时为两个子...原创 2020-01-11 10:16:05 · 138 阅读 · 0 评论