hdu 1689 Just a Hook】的更多相关文章

HDU.1689 Just a Hook (线段树 区间替换 区间总和) 题意分析 一开始叶子节点均为1,操作为将[L,R]区间全部替换成C,求总区间[1,N]和 线段树维护区间和 . 建树的时候初始化为1,更新区间时候放懒惰标记,下推标记更新区间和. 由于是替换,不是累加,所以更新的时候不是+=,而是直接=. 注意这点就可以了,然后就是多组数据注意memset,因为这个WA几发. 代码总览 #include <bits/stdc++.h> #define maxn 200010 #defin…
http://acm.hdu.edu.cn/showproblem.php?pid=1698 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 21930    Accepted Submission(s): 11005 Problem Description In the game of DotA, Pudge’s…
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…
Just a Hook Problem 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 ope…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1698 思路: 我的想法很简单,像上一题一样从后面向前面来算,前面已经覆盖的,后面自然不能再来计算了,具体是每次都计算覆盖的总长度,然后用这次的总长度减上次的总长度,自然就得到了这次覆盖的长度,可能我的方法不是很好吧!不过这是自己想出来的,再去借鉴一下别人的代码,多种想法是好的,毕竟是自己做的,因为数据不是很大所以不用离散化就可以 代码: #include<stdio.h> #include<a…
题目链接 题意 : 一个有n段长的金属棍,开始都涂上铜,分段涂成别的,金的值是3,银的值是2,铜的值是1,然后问你最后这n段总共的值是多少. 思路 : 线段树的区间更新.可以理解为线段树成段更新的模板题. //HDU 1698 #include <cstdio> #include <cstring> #include <iostream> using namespace std; ],p[] ; //lz延迟标记,每次更新不需要更新到底,使得更新延迟到下次更新或者查询的…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1698 题目: Problem 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 t…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=1698 题意:给出1~n的数,每个数初始为1,每次改变[a,b]的值,最后求1~n的值之和. 思路: 区间更新题目,关于懒惰标记什么的参考这个吧http://blog.sina.com.cn/s/blog_a2dce6b30101l8bi.html,讲得不错的. #include<iostream> #include<cstring> #include<algorithm> using…
2017-08-30 18:54:40 writer:pprp 可以跟上一篇博客做个对比, 这种实现不是很好理解,上一篇比较好理解,但是感觉有的地方不够严密 代码如下: /* @theme:segmentation/interval T @writer:pprp @begin:15:26 @end:16:13 @declare: 使用lazy标记的线段树,HDU 1698 这次写的是带结构体的那种 @date:2017/8/30 */ #include <iostream> #include…