传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1798 注意,应保证当前节点维护的值是正确的,lazy tag只是一个下传标记,在下传时应即时更新儿子的维护值,在修改时也应即时更新当前节点的维护值. #include <cstdio> const int maxn = 100005; int n, mod, a[maxn], m, t1, t2, t3, opr; struct Node { int ql, qr; long long
E. DZY Loves Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output DZY loves colors, and he enjoys painting. On a colorful day, DZY gets a colorful ribbon, which consists of n units (they
POJ 2777 Count Color --线段树Lazy的重要性 原题 链接:http://poj.org/problem?id=2777 Count Color Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 59087 Accepted: 17651 Description Chosen Problem Solving and Program design as an optional course, you are
题目链接:https://nanti.jisuanke.com/t/40852 题意:给定一个01串s,进行m次操作,|s|<=1e6,m<=5e5 操作有两种 l r 0,区间[l,r]升序排序 l r 1,区间[l,r]降序排序 输出m次操作后的串s 官方解析: 维护区间1的个数,区间0的个数=区间长度-区间1的个数,完成区间赋值操作并更新即可. 个人思路: 线段树的操作都是log(n),如果带了lazy标记,就可以小于log(n),不必查询到每个点.例如将[1,3]都置为1,只用将t[2
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 92921 Accepted: 28910 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of
题目 写了一天的线段树,这道题主要说明一下sum是赋值的,不是累加的,并且在push_down的时候lazy也是赋值的.因可能对懒标记的理解还不是很透彻吧. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int Max = 1e5+10; typedef long long ll; struct Tree{ int L,R; ll sum; int
Problem Description Chinese always have the railway tickets problem because of its' huge amount of passangers and stations. Now goverment need you to develop a new tickets query system.One train can just take k passangers. And each passanger can just
又是一开始觉得的水题,结果GG了好久的东西... 题意是给你n个英雄,每个英雄开始为1级经验为0,最多可以升到k级并且经验一直叠加,每一级都有一个经验值上限,达到就升级.接着给你两种操作:W li ri ei:从第li到第ri个增加经验基数ei,注意这儿ei还需要乘以级数才是真正增加的经验,还有就是先在此等级下增加此等级倍数的经验,然后再判断升级情况 Q li ri :在第li到第ri个查找经验最多的值 记录最大值嘛,不过因为级数控制增加的倍数,也就是说区间更新时,多次更新标记得到的只是基数ei
You are given a tree with N nodes. The tree’s nodes are numbered 1 through N and its edges are numbered 1 through N − 1. Each edge is associated with a weight. Then you are to execute a series of instructions on the tree. The instructions can be one
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 53749 Accepted: 16131 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of