QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#832851 | #9240. Mosaic | Flamire# | 12 | 74ms | 28944kb | C++17 | 1.7kb | 2024-12-26 09:37:13 | 2024-12-26 09:37:13 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define N 200011
using namespace std;
int a[4][N],b[N][4],val[N*2],n;
ll sum[N*2],sumi[N*2];
ll S2(int i,int j)
{
if(i<0||j<0)return 0;
if(j<=2)return b[i][j];
if(i<=2)return a[i][j];
return b[i][2]+a[2][j]-a[2][2];
}
ll query(int i,int j)
{
ll ans=S2(i,j);
// printf("first ans:%lld\n",ans);
if(i>=3&&j>=3)
{
int x1=3-i+n,x2=n,x3=j-i+n,x4=j-3+n;
if(x2>x3)swap(x2,x3);
int str=min(i,j)-2;
ans+=(sumi[x2]-sumi[x1-1])-1ll*(x1-1)*(sum[n]-sum[x1-1]);
ans+=1ll*str*(sum[x3]-sum[x2]);
ans+=1ll*(x4+1)*(sum[x4]-sum[x3])-(sumi[x4]-sumi[x3]);
}
// printf("query(%d,%d):%lld\n",i,j,ans);
return ans;
}
vector<ll> mosaic(vector<int> X,vector<int> Y,vector<int> U,vector<int> D,vector<int> L,vector<int> R)
{
n=max((int)X.size(),3);
for(int i=0;i<n;++i)a[1][i+1]=X[i];
for(int i=0;i<n;++i)b[i+1][1]=Y[i];
for(int i=2;i<=3;++i)a[i][1]=b[i][1],b[1][i]=a[1][i];
for(int i=2;i<=3;++i)
{
for(int j=2;j<=n;++j)a[i][j]=!(a[i-1][j]|a[i][j-1]);
}
for(int i=2;i<=n;++i)
{
for(int j=2;j<=3;++j)b[i][j]=!(b[i-1][j]|b[i][j-1]);
}
for(int i=3;i<=n;++i)val[i-3+n]=a[3][i],val[3-i+n]=b[i][3];
// printf("val:");for(int i=3-n+n;i<=n-3+n;++i)printf("%d ",val[i]);putchar(10);
for(int i=1;i<=2*n;++i)sum[i]=sum[i-1]+val[i],sumi[i]=sumi[i-1]+1ll*val[i]*i;
for(int i=1;i<=3;++i)for(int j=1;j<=n;++j)a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
for(int i=1;i<=n;++i)for(int j=1;j<=3;++j)b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
int q=U.size();
vector<ll> ans;
for(int i=0;i<q;++i)
{
++U[i];++D[i];++L[i];++R[i];
ans.push_back(query(D[i],R[i])-query(U[i]-1,R[i])-query(D[i],L[i]-1)+query(U[i]-1,L[i]-1));
}
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 11988kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 1 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 0 0 0 0 0 0 0 0 0 0
result:
ok
Test #2:
score: 5
Accepted
time: 1ms
memory: 10248kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 1 1 1 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1 1 1 1 1 1 1 1 1 1
result:
ok
Test #3:
score: 5
Accepted
time: 0ms
memory: 9892kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 1 0 1 0 10 1 1 0 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1 1 1 2 2 0 2 1 1 1
result:
ok
Test #4:
score: 5
Accepted
time: 1ms
memory: 9952kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 1 0 1 0 10 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 0 1 1 1 1 0 0 0 1 0 1 0 0 1 1 0 0
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1 2 1 1 2 1 1 1 1 0
result:
ok
Test #5:
score: 5
Accepted
time: 1ms
memory: 9944kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 0 1 0 0 10 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 0 1 0 0 0 0 1 1 1 1
result:
ok
Test #6:
score: 5
Accepted
time: 1ms
memory: 9944kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 1 1 1 0 10 0 0 0 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 0 0 1 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 2 2 0 2 1 1 0 1 1 1
result:
ok
Test #7:
score: 5
Accepted
time: 1ms
memory: 9964kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 0 0 0 1 10 0 0 0 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 1 1 1 0 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 0 1 1 1 0 0 0 1 1 1
result:
ok
Test #8:
score: 5
Accepted
time: 0ms
memory: 9944kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 1 0 1 1 10 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 1 1 1 0 1 0 1 0 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 2 1 1 0 1 0 2 0 1 2
result:
ok
Test #9:
score: 5
Accepted
time: 0ms
memory: 9924kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 0 1 0 1 10 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 1 0 0 0 1 0 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 2 2 0 2 1 2 1 0 1 2
result:
ok
Test #10:
score: 5
Accepted
time: 0ms
memory: 7940kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 2 1 1 1 1 10 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 1 1 1 1
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 2 2 2 3 1 3 3 1 3 0
result:
ok
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #11:
score: 0
Wrong Answer
time: 1ms
memory: 8216kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199 0 0 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 1 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1474 7437 1733 492 12426 -4 1403 3557 -1755 2296 34 430 1125 7696 6845 829 127 3 26 885 1259 54 1900 49 3289 1023 2 3015 955 5014 5841 2989 -4 3781 1195 5 4260 20 327 4181 520 1207 676 1643 87 4557 2903 1954 11 4193 1721 7072 1577 2062 1463 2439 75 11170 1603 4084...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1078', found: '1474'
Subtask #3:
score: 7
Accepted
Test #18:
score: 7
Accepted
time: 65ms
memory: 28728kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 0 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 1 0 1 1 0 0 0 0 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1314 79312 13238 63518 27135 86532 21129 53105 14461 13920 65981 66950 13385 23885 37091 56646 69855 64947 74166 41759 50738 1366 65318 58452 24337 58380 29379 59258 39016 4990 60529 23351 60370 12835 25686 8151 17007 56172 10913 7224 30221 73673 55593 33643 44070...
result:
ok
Test #19:
score: 7
Accepted
time: 68ms
memory: 28844kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 0 1 1 0 0 1 1 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 97288 84412 98958 98546 95894 91536 99791 94852 96879 98784 94005 99030 95916 90829 96593 96545 90518 95251 93882 95122 94925 96009 98788 98866 95996 97263 95422 95733 96576 97730 98106 96939 94030 94576 94019 92982 96921 95715 96639 93579 97372 97983 95123 95211 ...
result:
ok
Test #20:
score: 7
Accepted
time: 62ms
memory: 28944kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 200000 1 0 0 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 0 1 1 0 1 1 0 0 1 0 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 63186 59869 80378 71302 94439 63006 84372 99459 21243 54879 86436 65742 94261 35276 55849 93734 72881 49090 34951 93280 90257 58145 84070 58055 95069 56733 82475 51301 59357 39555 95572 87255 37523 68017 80309 52815 95469 29140 85700 46052 56013 71305 90947 7434 6...
result:
ok
Test #21:
score: 7
Accepted
time: 62ms
memory: 28764kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 200000 1 0 0 0 1 1 0 1 0 1 1 0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 0 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 1 1 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 99156 96398 98499 93058 98359 93547 93120 98997 99065 97926 99050 95046 96687 98137 97249 97530 96983 98126 89892 94397 98111 96471 95754 99320 97511 95029 96780 93937 97095 97566 97024 99338 97729 99722 97152 98216 95895 97942 98980 99845 96992 97397 99255 97894 ...
result:
ok
Test #22:
score: 7
Accepted
time: 52ms
memory: 25400kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 100000 0 0 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 0 0 1 0 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 1 0 1 1 1 0 1 1 0 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 34862 31357 15637 16893 7670 123 17919 20936 7467 18723 34082 1835 18668 23866 630 26206 40304 6217 25617 18490 11507 39163 5570 16345 4695 30449 15992 13307 5315 5393 8864 29876 34139 3227 28910 11628 2250 38538 12586 299 1066 8238 40627 7418 7600 3123 18111 9012...
result:
ok
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 38ms
memory: 17804kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 200000 1 7 0 4 3 4 3 4 3 6 2 5 4 5 6 7 5 7 2 8 0 6 4 7 0 5 6 7 1 3 9 9 6 9 1 7 2 9 4 6 4 4 6 7 0 1 8 8 7 7 0 3 0 4 1 7 2 2 0 9 3 9 4 6 3 9 0 9 1 8 4 6 4 5 5 7 0 6 2 3 2 3 0 6 1 9 8 8 2 4 3 4 3 6 2 9 3 9 2 7 1 3 0 3 0 8 2 4 3...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 6 9 3 2 10 22 5 2 12 14 1 0 4 14 4 12 32 18 9 -4 6 4 10 16 19 5 6 18 -1 15 3 3 7 -5 2 9 6 5 -1 9 15 22 2 -4 15 5 20 3 4 6 7 11 23 0 -2 4 11 4 4 4 -5 3 1 3 30 32 4 5 -1 11 7 12 19 10 4 4 12 1 4 10 8 9 11 7 6 20 18 1 2 9 10 14 33 14 5 3 3 8 7 22 20 10 6 5 3 12 16 8 ...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '14', found: '6'
Subtask #6:
score: 0
Wrong Answer
Test #42:
score: 0
Wrong Answer
time: 74ms
memory: 28764kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 0 1 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 1 1 0 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 0 0 0 0 1 0 1 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK -89090 1 0 1 0 60722 0 -12150 12431 57071 1 1 -57697 1102 0 62539 1 1 -42731 0 1 1 1 0 0 14427 0 0 0 1 -12360 -182579 1 -13287 1 -66864 1 1 26761 1 1 0 22757 -10289 0 -166897 -22182 1 1 -34524 1 -57328 0 0 86015 -51749 0 -131510 0 3067 -119458 1 0 0 0 -182779 1 0 ...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '0', found: '-89090'
Subtask #7:
score: 0
Skipped
Dependency #3:
100%
Accepted
Dependency #6:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%