Just a Hook (线段树)】的更多相关文章

hdu_1698Just a Hook(线段树) 标签: 线段树 题目链接 题意: 一个英雄的技能是发射一个长度为n的金属链,初始的金属链都是铁做的,标记为1,我们可以对于某个区间修改它的金属材质,如果修改为银的标号为2,金的标号为3,现在问你经过一系列的修改后整条链子上的标记和为多少 题解: 很容易想到这个题和区间染色的问题很像 代码: #include<cstdio> #include<cstring> #include<algorithm> using names…
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 [题目链接]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<&…
最近刚学线段树,做了些经典题目来练手 Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 24370 Accepted Submission(s): 12156 Problem Description In the game of DotA, Pudge's meat hook is actually the most h…
Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 23229    Accepted Submission(s): 11634 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing…
题目链接 题意: n个挂钩,q次询问,每个挂钩可能的值为1 2 3,  初始值为1,每次询问 把从x到Y区间内的值改变为z.求最后的总的值. 分析:用val记录这一个区间的值,val == -1表示这个区间值不统一,而且已经向下更新了, val != -1表示这个区间值统一, 更新某个区间的时候只需要把这个区间分为几个区间更新就行了, 也就是只更新到需要更新的区间,不用向下更新每一个一直到底了,在更新的过程中如果遇到之前没有向下更新的, 就需要向下更新了,因为这个区间的值已经不统一了. 其实这就…
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…
转载请注明出处:http://blog.csdn.net/u012860063 题目链接: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 consecut…
解题报告 题意: 原本区间1到n都是1,区间成段改变成一个值,求最后区间1到n的和. 思路: 线段树成段更新,区间去和. #include <iostream> #include <cstdio> #include <cstring> using namespace std; int sum[500000],lz[500000]; void push_up(int root,int l,int r) { sum[root]=sum[root*2]+sum[root*2+…
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…