QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#142011 | #4918. 染色 | pzr | 0 | 1168ms | 302388kb | C++14 | 2.9kb | 2023-08-18 10:54:19 | 2023-08-18 10:54:21 |
Judging History
answer
#include<bits/stdc++.h>
#define ll unsigned long long
#define N 300010
using namespace std;
int n,m,op,a[1010][1010],x,l,r,s[1010][1010],now,g[12][N*4],bz[12][N*4];
ll sum[1010],ans,v,f[12][N*4],bf[12][N*4];
void pushdown(int t,int k,int l,int r,int mid){
f[t][k*2]+=bf[t][k]*g[t][k*2];f[t][k*2+1]+=bf[t][k]*g[t][k*2+1];
if(bz[t][k*2]!=1)bf[t][k*2]+=bf[t][k];
if(bz[t][k*2+1]!=1)bf[t][k*2+1]+=bf[t][k];
bf[t][k]=0;
if(bz[t][k]!=-1){
bz[t][k*2]=bz[t][k*2+1]=bz[t][k];
if(bz[t][k]==0)g[t][k*2]=mid-l+1,g[t][k*2+1]=r-mid;
else if(bz[t][k]==1)g[t][k*2]=g[t][k*2+1]=0;
bz[t][k]=-1;
}
}
void update(int t,int k){
f[t][k]=f[t][k*2]+f[t][k*2+1];
g[t][k]=g[t][k*2]+g[t][k*2+1];
}
void join(int t,int k,int l,int r,int x,int y,int z){
int mid=(l+r)>>1;
pushdown(t,k,l,r,mid);
if(l>=x&&r<=y){
bz[t][k]=z;
if(!z)g[t][k]=r-l+1;
else g[t][k]=0;
return;
}
if(x<=mid)join(t,k*2,l,mid,x,y,z);
if(y>mid)join(t,k*2+1,mid+1,r,x,y,z);
update(t,k);
}
void add(int t,int k,int l,int r,int x,int y,ll z){
int mid=(l+r)>>1;
pushdown(t,k,l,r,mid);
if(l>=x&&r<=y){
bf[t][k]+=z;f[t][k]+=g[t][k]*z;
return;
}
if(x<=mid)add(t,k*2,l,mid,x,y,z);
if(y>mid)add(t,k*2+1,mid+1,r,x,y,z);
update(t,k);
}
int get(int t,int k,int l,int r,int x,int y){
if(l>=x&&r<=y)return g[t][k];
int mid=(l+r)>>1,sum=0;pushdown(t,k,l,r,mid);
if(x<=mid)sum+=get(t,k*2,l,mid,x,y);
if(y>mid)sum+=get(t,k*2+1,mid+1,r,x,y);
return sum;
}
ll find(int t,int k,int l,int r,int x,int y){
if(l>=x&&r<=y)return f[t][k];
int mid=(l+r)>>1;ll sum=0;pushdown(t,k,l,r,mid);
if(x<=mid)sum+=find(t,k*2,l,mid,x,y);
if(y>mid)sum+=find(t,k*2+1,mid+1,r,x,y);
return sum;
}
int main(){
// freopen("paint.in","r",stdin);
// freopen("paint.out","w",stdout);
scanf("%d%d",&n,&m);
if(n<=1000&&m<=1000){
for(;m;m--){
scanf("%d",&op);
if(op==1){
scanf("%d%d%d",&l,&r,&x);
for(int i=l;i<=r;i++)a[i][x]=1;
for(int i=1;i<=n;i++)
s[i][x]=s[i-1][x]+a[i][x];
}else if(op==2){
scanf("%d%d%d",&l,&r,&x);
for(int i=l;i<=r;i++)a[i][x]=0;
for(int i=1;i<=n;i++)
s[i][x]=s[i-1][x]+a[i][x];
}else if(op==3){
scanf("%d%d%llu",&l,&r,&v);now=m+1;
for(int i=1;i<=m;i++)
if(s[i][r]-s[i][l-1]!=r-l+1)
{now=i;break;}
for(int i=l;i<=r;i++)
if(!a[i][now])sum[i]+=v;
}else if(op==4){
scanf("%d%d",&l,&r);ans=0;
for(int i=l;i<=r;i++)ans+=sum[i];
printf("%llu\n",ans);
}
}return 0;
}
for(;m;m--){
scanf("%d",&op);
if(op==1){
scanf("%d%d%d",&l,&r,&x);
join(x,1,1,n,l,r,1);
}else if(op==2){
scanf("%d%d%d",&l,&r,&x);
join(x,1,1,n,l,r,0);
}else if(op==3){
scanf("%d%d%llu",&l,&r,&v);now=11;
for(int i=1;i<=10;i++)
if(get(i,1,1,n,l,r)!=r-l+1){now=i;break;}
add(now,1,1,n,l,r,v);
}else if(op==4){
scanf("%d%d",&l,&r);ans=0;
for(int i=1;i<=11;i++)
ans+=find(i,1,1,n,l,r);
printf("%llu\n",ans);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 7ms
memory: 14688kb
input:
1000 1000 3 722 914 2141556875752121755 3 323 347 6433743606947304931 2 142 206 439 2 117 840 195 2 127 502 56 3 168 707 15142638115094015116 4 190 257 2 88 976 475 1 319 867 351 1 682 889 409 2 406 446 196 3 28 35 4899387534800369959 2 291 546 150 1 528 617 128 1 58 122 251 2 381 400 276 4 510 958 ...
output:
15128467772367689008 17361914246216994339 5483226026482017320 3033562207293358603 2081407883485577238 7431958406282818646 4664359672511637691 8517692808398202534 17884251128335023776 3389445997760709607 15161173652136060523 17246899135664170339 16659472119973467421 5618344994614112283 92650283427734...
result:
ok 288 tokens
Test #2:
score: -10
Wrong Answer
time: 4ms
memory: 11612kb
input:
1000 1000 1 538 681 44 2 112 540 10 1 160 191 28 1 276 867 1 4 118 419 4 62 209 1 575 884 37 1 783 895 45 4 342 410 2 545 870 16 1 273 501 11 3 258 352 13270291835335737625 3 490 514 5208698592597571883 2 629 865 43 3 966 981 14431353048791951405 1 290 809 16 4 468 843 1 607 875 26 2 177 521 6 4 176...
output:
0 0 0 0 17504324151528657858 2987455658418197192 0 0 13815347553406398201 5603739312727078592 17885258495700927170 0 6074848198900056536 5600801614830233724 849737692109005723 7987405179460566712 11167555038801075052 9849982750066132052 7566556261498476947 4770359948078301544 9381293826472157564 0 1...
result:
wrong answer 4th words differ - expected: '1090256298972435763', found: '0'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 1168ms
memory: 302388kb
input:
300000 300000 1 237576 237663 1 3 16150 16208 9270412155482010138 2 175648 175692 1 4 190836 190849 4 199010 199097 1 73976 298801 1 3 89902 89939 6418828085116455990 3 55415 55461 12238963685511262676 3 119825 119875 8146944792877919309 3 135103 135158 218634681842812119 3 127261 127352 13291431184...
output:
0 0 0 0 0 0 2619402094145070066 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9776641937911623199 0 0 3841760915653877891 4839081618674768079 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16405055670544192082 0 0 0 0 0 0 0 0 0 13745969425832275248 0 0 0 0 4469437221705180832 0 0 0 0 0 0 15733886747087790485 0 3065992016017...
result:
wrong answer 7th words differ - expected: '12272376591028786218', found: '2619402094145070066'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Runtime Error
Test #31:
score: 0
Runtime Error
input:
300000 300000 1 85444 86076 59 1 41150 41411 71 1 278698 279414 45 1 238445 239202 56 1 29965 29984 49 1 282953 283272 37 1 34668 35653 86 2 198587 198744 28 1 270855 271611 58 1 2130 2965 773 1 161601 162298 937 1 50299 50435 36 1 100759 101198 64 1 120208 120543 84 1 295293 295732 34 1 112185 1129...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%