/*
TASK:hdu1698
*/
#include<iostream>
#include<cstdio>
const int maxn=100000+10,maxm=100000+10;
using namespace std;
int a[maxn<<2],ans;
void ts(int h,int s,int t,int L,int R,int ys){
if(L<=s && t<=R)a[h]=ys;
else{
if(a[h]>=0){
a[h*2]=a[h*2+1]=a[h];
a[h]=-1;
}
if(L<=(s+t)/2)ts(h*2,s,(s+t)/2,L,R,ys);
if((s+t)/2+1<=R)ts(h*2+1,(s+t)/2+1,t,L,R,ys);
}
}
void cal(int h,int s,int t){
if(a[h]>=0)ans+=a[h]*(t-s+1);
else{
cal(h*2,s,(s+t)/2);
cal(h*2+1,(s+t)/2+1,t);
}
}
int main(){
int i,j,k,m,n,x,y,z,c;
cin>>c;
for(k=1;k<=c;k++){
ans=0;
cin>>n>>m;
a[1]=1;
for(i=1;i<=m;i++){
scanf("%d%d%d",&x,&y,&z);
ts(1,1,n,x,y,z);
}
cal(1,1,n);
printf("Case %d: The total value of the hook is %d.\n",k,ans);
}
return 0;
}
HDU1698(線段樹LAZY)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.