HDU_1698 Just a Hook(线段树+lazy标记)】的更多相关文章

pid=1698">题目请点我 题解: 接触到的第一到区间更新,须要用到lazy标记.典型的区间着色问题. lazy标记详情请參考博客:http://ju.outofmemory.cn/entry/99351 简单讲就是被lazy标记的非叶子节点所包括的全部叶子节点具有同样的性质.当更新或查询到该区间时,不再向下递归.仅对当前节点的lazy标记进行改动. update : 假设当前区间刚好全然在目的区间内:看当前节点是否被标记.若未被标记.或者被标记了可是与要更新类型同样,不再向下更新.仅…
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…
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…
题目链接: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…
lazy写崩了--. 查了好久 /* U-> [l,r]–>1 I-> [1,l-1] [r+1,+无穷] –>0 D-> [l,r]–>0 C-> [1,l-1] [r+1,+无穷]–>0 xor[l,r] S-> [l,r]–>xor */ //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using names…
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define INF 0X3f3f3f3f ; ; ll a[MAXN]; struct node { int left, right; //区间端点 ll max, sum; //看题目要求 ll lazy; void update(ll x) { sum += (right - left +…
 分析:https://www.bilibili.com/read/cv4777102 #include <cstdio> #include <algorithm> using namespace std; ; ]; int L,R,C,n,m,q; #define ls t[x].l #define rs t[x].r ;))ans++;return ans;} ;} void update(int x){t[x].color=t[ls].color|t[rs].color;}…
Nice boat Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 335    Accepted Submission(s): 159 Problem Description There is an old country and the king fell in love with a devil. The devil al…
Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 30553    Accepted Submission(s): 15071 Problem Description In the game of DotA, Pudge's meat hook is actually the most horrible thing…
HDU.1689 Just a Hook (线段树 区间替换 区间总和) 题意分析 一开始叶子节点均为1,操作为将[L,R]区间全部替换成C,求总区间[1,N]和 线段树维护区间和 . 建树的时候初始化为1,更新区间时候放懒惰标记,下推标记更新区间和. 由于是替换,不是累加,所以更新的时候不是+=,而是直接=. 注意这点就可以了,然后就是多组数据注意memset,因为这个WA几发. 代码总览 #include <bits/stdc++.h> #define maxn 200010 #defin…