ORZ
#include<cstdio> #include<string.h> using namespace std; const int N=100005; int num[N<<2],col[N<<2]; #define lson l, mid, rt << 1 #define rson mid+1, r, rt << 1 | 1 void PushUp(int rt) { num[rt]=num[rt<<1]+num[rt<<1|1]; } void PushDown(int rt,int len) { if(col[rt]) { col[rt<<1]=col[rt]; col[rt<<1|1]=col[rt]; num[rt<<1]=(len-(len>>1))*col[rt]; num[rt<<1|1]=(len>>1)*col[rt]; col[rt]=0; } } void build(int l,int r,int rt) { col[rt]=0; num[rt]=1; if(l==r) return; int mid=(l+r)>>1; build(lson); build(rson); PushUp(rt); } void update(int L,int R,int v,int l,int r,int rt) { if(L<=l&&R>=r)//刚开始这里写反了写成L>=l一直runtime error 各种弱爆了 爱酱DBL { col[rt]=v; num[rt]=v*(r-l+1); return; } PushDown(rt,r-l+1); int mid=(l+r)>>1; if(mid>=L) update(L,R,v,lson); if(mid<R) update(L,R,v,rson); PushUp(rt); } int main() { int t; int a,b,c,n,m; scanf("%d",&t); for(int i=1;i<=t;i++) { scanf("%d%d",&n,&m); build(1,n,1); //scanf("%d",&m); while(m--) { scanf("%d%d%d",&a,&b,&c); update(a,b,c,1,n,1); } printf("Case %d: The total value of the hook is %d.\n",i,num[1]); } return 0; }