QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#832867 | #9240. Mosaic | dongyc666# | 5 | 85ms | 107680kb | C++17 | 2.1kb | 2024-12-26 09:49:20 | 2024-12-26 09:49:21 |
Judging History
answer
#include "mosaic.h"
#include <bits/stdc++.h>
#define int long long
#define si signed
using namespace std;
const int NR=2e5+15;
const int M=10;
int n,v[15][15],a1[NR][15],a2[15][NR],pre1[NR][15],pre2[15][NR],val[NR*2],s0[NR*2],s1[NR*2];
int calc0(int l,int r){return s0[r]-s0[l-1];}
int calc1(int l,int r){return s1[r]-s1[l-1];}
int calc(int l,int r,int k){
int v1=calc1(l,l+k-1)-(l-1)*calc0(l,l+k-1);
int v2=(r+1)*calc0(r-k+1,r)-calc1(r-k+1,r);
int con=calc0(l+k,r-k)*(k+1);
return v1+v2+con;
}
vector<int> mosaic(vector<si> X, vector<si> Y,
vector<si> T, vector<si> B,
vector<si> L, vector<si> R) {
n=X.size();
for(int i=0;i<n;i++)a2[0][i]=X[i],a1[i][0]=Y[i];
for(int i=0;i<M;i++)v[0][i]=a2[0][i],v[i][0]=a1[i][0];
for(int i=1;i<M;i++)
for(int j=1;j<M;j++)
v[i][j]=!(v[i-1][j]|v[i][j-1]);
for(int i=0;i<M;i++)
for(int j=0;j<M;j++)
a1[i][j]=a2[i][j]=v[i][j];
for(int i=M;i<n;i++)
for(int j=1;j<M;j++)a1[i][j]=!(a1[i-1][j]|a1[i][j-1]);
for(int i=1;i<M;i++)
for(int j=M;j<=n;j++)a2[i][j]=!(a2[i-1][j]|a2[i][j-1]);
for(int i=0;i<=n;i++)
for(int j=0;j<M;j++)
pre1[i][j]=a1[i][j]+((i>0)?pre1[i-1][j]:0);
for(int i=0;i<M;i++)
for(int j=0;j<=n;j++)
pre2[i][j]=a2[i][j]+((j>0)?pre2[i][j-1]:0);
// for(int i=0;i<M;i++){
// for(int j=0;j<M;j++)cout<<pre1[i][j]<<' ';
// cout<<endl;
// }
for(int i=M;i<=n;i++)
val[(M-1)-i+n]=a2[M-1][i],val[i-(M-1)+n]=a1[i][M-1];
val[n]=v[M-1][M-1];
for(int i=1;i<=2*n;i++)
s0[i]=s0[i-1]+val[i],s1[i]=s1[i-1]+val[i]*i;
int q=T.size();
vector<int>ans;
for(int i=0;i<q;i++){
int u=T[i],d=B[i],l=L[i],r=R[i],res=0;
for(int i=l;i<=min(M-1,r);i++){
if(u)res+=pre1[d][i]-pre1[u-1][i];
else res+=pre1[d][i];
}
l=max(l,M);
if(u>d||l>r){
ans.push_back(res);
continue;
}
for(int i=u;i<=min(M-1,d);i++){
if(u)res+=pre2[i][r]-pre2[i][l-1];
else res+=pre2[i][r];
}
u=max(u,M);
if(u>d||l>r){
ans.push_back(res);
continue;
}
int k=min(r-l,d-u);
res+=calc(u-r+n,d-l+n,k);
ans.push_back(res);
}
return ans;
}
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 42716kb
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: 3ms
memory: 42724kb
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: 42728kb
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: 0ms
memory: 43024kb
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: 0ms
memory: 42788kb
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: 0ms
memory: 42768kb
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: 0ms
memory: 42732kb
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: 42692kb
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: 42800kb
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: 3ms
memory: 42676kb
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: 0ms
memory: 43028kb
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 1078 5276 897 428 10378 1260 1733 4327 697 1864 34 430 709 5682 5295 625 39 10 196 416 3048 87 4065 49 1368 1220 80 1440 1083 5053 5561 2680 56 2539 1107 57 3705 1996 327 2789 432 1542 571 1643 756 5253 1931 1934 245 3545 2026 4364 935 1506 1992 1815 75 9847 1279 ...
result:
wrong answer 4th lines differ - on the 1st token, expected: '5062', found: '5276'
Subtask #3:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 72ms
memory: 107680kb
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 23109 98387 97054 91921 85581 89142 61366 59595 72244 63217 78300 97147 29901 40697 60009 92700 77647 69124 93392 50508 79137 68597 92137 74119 35908 76804 36811 64125 96428 46125 94157 36343 65757 23039 68091 25317 37923 86213 34147 70411 49519 76544 66237 69340 ...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1314', found: '23109'
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 8
Accepted
time: 39ms
memory: 50408kb
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 14 2 8 2 10 12 5 2 14 12 1 0 2 14 4 10 32 12 3 6 6 4 3 16 21 5 12 6 7 11 12 3 7 3 6 15 6 4 6 8 15 24 2 5 11 8 16 3 4 12 4 9 23 1 2 5 6 4 1 4 4 3 6 4 18 32 10 2 7 7 5 12 11 7 4 4 10 6 4 16 8 13 8 3 3 8 21 1 2 3 6 14 21 14 9 2 3 2 4 16 20 7 3 5 3 15 16 8 36 7 6 7 9 ...
result:
ok
Test #32:
score: 0
Wrong Answer
time: 85ms
memory: 105780kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 199999 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 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 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 0 0 0 0 0 0 0 0 0 0 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 8120124544 2752273618 652362120 3572900496 7229702005 8480641653 6918084280 1267958106 904477638 1997350413 7012230475 1362860576 163899948 797037988 656632144 5591112615 3071773904 8768430125 4850111320 8165741606 1554651170 1797902728 374751575 9903806946 519998...
result:
wrong answer 49982nd lines differ - on the 1st token, expected: '713128916', found: '713583169'
Subtask #6:
score: 0
Wrong Answer
Test #42:
score: 22
Accepted
time: 75ms
memory: 105620kb
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 0 1 0 1 0 1 0 0 1 1 1 1 0 1 0 1 1 1 0 0 1 1 1 0 0 1 0 0 0 1 0 0 1 0 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 1 0 1 1 0 1 1 1 1 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 ...
result:
ok
Test #43:
score: 22
Accepted
time: 81ms
memory: 105712kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 200000 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 1 1 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 1 0 1 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 1 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 ...
result:
ok
Test #44:
score: 0
Wrong Answer
time: 78ms
memory: 105640kb
input:
njJ9Z7VxxKGR6SUcJMgdzy3qMz4JZ1Tq 200000 1 0 0 0 0 1 0 0 0 1 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1 1 1 0 1 0 0 0 1 0 0 0 1 0 1 1 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 1 ...
output:
Wm5rkGNobnYjFI7TIY17RAm6FAQ2LlO9 OK 0 1 1 0 1 0 0 1 0 0 1 0 0 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 1 1 1 1 0 504 1 1 0 0 0 0 0 0 1 1 0 0 0 0 1 44163 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 0 78217 0 1 1 1 1 0 0 68825 1 1 0 1 0 1 0 0 0 1 56333 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 1 ...
result:
wrong answer 46th lines differ - on the 1st token, expected: '0', found: '504'
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%