hdu Just a Hook
来源:互联网 发布:公共卫生学mac 编辑:程序博客网 时间:2024/05/19 23:14
成段更新,注意延迟标记。
#include <stdio.h>
#define maxn 100050#define lson l , m , rt *2
#define rson m+1 , r , rt *2 +1
#define dem int m = (l + r) / 2
int sum[maxn*4];
int col[maxn*4];
int n;
void PushUp(int rt){
sum[rt] = sum[rt*2] + sum[rt*2+1];
}
void PushDown(int rt,int m){
if(col[rt]){
col[rt*2] = col[rt*2+1] = col[rt];
sum[rt*2] = (m - m/2) * col[rt];
sum[rt*2+1] = (m / 2) * col[rt];
col[rt] = 0;
}
}
void build(int l,int r,int rt){
col[rt] = 0;
if(l == r) {
sum[rt] = 1;
return ;
}
int m = (l + r) / 2;
build(lson);
build(rson);
PushUp(rt);
}
void update(int L,int R,int value,int l,int r,int rt){
if(L <= l && r <= R){
sum[rt] = (r - l + 1) * value;
col[rt] = value;
return ;
}
PushDown(rt,r-l+1);
int m = (l + r) / 2;
if(L <= m) update(L,R,value,lson);
if(R > m)update(L,R,value,rson);
PushUp(rt);
}
int main()
{
int T,Q,a,b,x;
scanf("%d",&T);
for(int i=1;i<=T;i++)
{
scanf("%d",&n);
build(1,n,1);
scanf("%d",&Q);
while(Q--)
{
scanf("%d%d%d",&a,&b,&x);
update(a,b,x,1,n,1);
}
/*for(int j=1;j<=n*4;j++)
printf("%d ",sum[j]);
*/
printf("Case %d: The total value of the hook is %d.\n",i,sum[1]);
}
}
- hdu Just a Hook
- HDU Just a Hook
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook (HDU
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook HDU
- Just a Hook HDU
- hdu 1698 Just a Hook
- hdu 1698 Just a Hook
- Hdu 1698 Just a Hook
- hdu 1698 Just a Hook
- hdu 1698 just a hook
- hdu 1698 Just a Hook
- 新手上路,求前辈带路....
- 2012.07.04
- centOs中文 英文界面转换
- IIC总线
- Magento认证工程师考试教程
- hdu Just a Hook
- Junit4所需jar包
- Nand Flash -详述(2)
- C/C++中float和double的存储结构
- phpmyadmin配置信息
- eclipse中tomcat发布项目配置
- Foursquare 源码研究之---------用户登录
- java泛型
- Foursquare 源码研究之------登录续