hdu 1698区间延迟更新】的更多相关文章

#include<stdio.h> #define N 100100 struct node { int x,y,yanchi; }a[N*4];//注意数组范围 void build(int t,int x,int y) { a[t].x=x; a[t].y=y; a[t].yanchi=1; if(x==y) return ; int temp=t<<1; int mid=(x+y)/2; build(temp,x,mid); build(temp+1,mid+1,y); }…
Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20532    Accepted Submission(s): 10284 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing…
656mS #include<stdio.h> #include<stdlib.h> #define N 110000 struct node { int x,y,yanchi,sum; }a[N*10]; void build(int t,int x,int y) { a[t].x=x; a[t].y=y; a[t].sum=0; a[t].yanchi=0; if(x==y)return ; int temp=t*2; int mid=(a[t].x+a[t].y)/2; bu…
#include<stdio.h> #include<string.h> #define N 100000 struct st{  int x,y;  __int64 yanchi,sum; }a[N*4]; __int64 b[N]; void build(int t,int x,int y) {  a[t].x=x;  a[t].y=y;  a[t].yanchi=0;  if(x==y) {   a[t].sum=b[x];   return ;  }  int temp=t…
题目地址:pid=1698">HDU 1698 区间替换裸题.相同利用lazy延迟标记数组,这里仅仅是当lazy下放的时候把以下的lazy也所有改成lazy就好了. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring> #include <stdlib.h> #include <math.h> #includ…
先说说区间更新和单点更新的区别 主要的区别是搜索的过程 前者需要确定一个区间 后者就是一个点就好了 贴上两者代码 void updata(int i)//单点更新 { int l=stu[i].l; int r=stu[i].r; int mid=(l+r)/2;//二分咯 if(l==r&&r==x)//x为目标id 当左右节点相同的时候 就是找到这个数的时候 { stu[i].maxx=y; return; } if(l<=x&&x<=mid) updata…
题目链接 题意 : 一个有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 区间更新重点在于懒惰标记. 当你更新的区间就是整个区间的时候,直接sum[rt] = c*(r-l+1);col[rt] = c:后面的子区间就不管了,当你下次更新某一个区间的时候,把col[rt]从顶往下推(也没有推到底),推到合适的位置,刚好这个位置是我要更新的区间的子区间(可能被横跨了)就停下来. 在这里感谢网上的大牛,感谢杰哥,彬哥.我才能AC. Just a Hook Time Li…
题目链接: 传送门 Minimum Inversion Number Time Limit: 1000MS     Memory Limit: 32768 K 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…
题目网址: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…