Just a Hook [题目链接]Just a Hook [题目类型]线段树 区间替换 &题解: 线段树 区间替换 和区间求和 模板题 只不过不需要查询 题里只问了全部区间的和,所以seg[1] 就是answer [时间复杂度]\(O(nlogn)\) &代码: #include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 9 ; int n,q,x,y,z; int seg[maxn<&…
Description: In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do some operations on the hook…
描述 In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do some operations on the hook. Let us n…
Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18378    Accepted Submission(s): 9213 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing f…
题目地址:pid=1698">HDU 1698 区间替换裸题.相同利用lazy延迟标记数组,这里仅仅是当lazy下放的时候把以下的lazy也所有改成lazy就好了. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #includ…
来谈谈自己对延迟标记(lazy标记)的理解吧. lazy标记的主要作用是尽可能的降低时间复杂度. 这样说吧. 如果你不用lazy标记,那么你对于一个区间更新的话是要对其所有的子区间都更新一次,但如果用lazy标记的话. 就只需要更新这一个区间然后加一个标记,那么如果要访问这个区间的子区间,因为有lazy标记,所以下次访问会将区间的lazy标记传递给子区间,让后去更新子区间,这样我们不必在每次区间更新操作的时候更新该区间的全部子区间,等下次查询到这个区间的时候只需要传递lazy标记就可以了 但从时…
HDU.1689 Just a Hook (线段树 区间替换 区间总和) 题意分析 一开始叶子节点均为1,操作为将[L,R]区间全部替换成C,求总区间[1,N]和 线段树维护区间和 . 建树的时候初始化为1,更新区间时候放懒惰标记,下推标记更新区间和. 由于是替换,不是累加,所以更新的时候不是+=,而是直接=. 注意这点就可以了,然后就是多组数据注意memset,因为这个WA几发. 代码总览 #include <bits/stdc++.h> #define maxn 200010 #defin…
Just a Hook Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1698 Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several cons…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=1698 n个数初始每个数的价值为1,接下来有m个更新,每次x,y,z 把x,y区间的数的价值更新为z(1<=z<=3),问更新完后的总价值. 线段树的区间更新,需要用到延迟标记,简单来说就是每次更新的时候不要更新到底,用延迟标记使得更新延迟到下次需要更新或者询问的时候. 这题只需要输出总区间的信息,即直接输出1结点的信息. #include <iostream> #include <cstd…