QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#553223 | #9240. Mosaic | thomaswmy# | 0 | 78ms | 28048kb | C++14 | 1.6kb | 2024-09-08 10:52:36 | 2024-09-08 10:52:37 |
Judging History
answer
#include <bits/stdc++.h>
#include "mosaic.h"
using namespace std;
const int N=2e5+10;
typedef long long ll;
int n,q;
bool ax[N][3],ay[3][N];
int sx[N][3],sy[3][N];
ll ssx[N][3],ssy[3][N];
ll calc(int x,int y) {
if(!x || !y) return 0;
ll res=sx[x][1]+sy[1][y]-ax[1][1];
if(x<=y) {
res+=1ll*(x+1)*(sx[x][2]-sx[1][2])-(ssx[x][2]-ssx[1][2]);
res+=1ll*(y+1)*(sy[2][y]-sy[2][y-x+2])-(ssy[2][y]-ssy[2][y-x+2])+1ll*(x-1)*(sy[2][y-x+2]-sy[2][2]);
}
else {
res+=1ll*(y+1)*(sy[2][y]-sy[2][1])-(ssy[2][y]-ssy[2][1]);
res+=1ll*(x+1)*(sx[x][2]-sx[x-y+2][2])-(ssx[x][2]-ssx[x-y+2][2])+1ll*(y-1)*(sx[x-y+2][2]-sx[2][2]);
}
return res;
}
vector<ll> mosaic(vector<int> X,vector<int> Y,vector<int> T,vector<int> B,vector<int> L,vector<int> R) {
n=X.size(),q=T.size();
swap(X,Y);
if(n==1) {
vector<ll> res;
res.resize(q,X[0]);
return res;
}
for(int i=1;i<=n;i++) ax[i][1]=X[i-1];
for(int i=1;i<=n;i++) ay[1][i]=Y[i-1];
ax[1][2]=ay[1][2],ay[2][1]=ax[2][1];
for(int i=2;i<=n;i++) ax[i][2]=(!ax[i-1][2]) && (!ax[i][1]),ay[2][i]=(!ay[1][i]) && (!ay[2][i-1]);
for(int i=1;i<=2;i++) {
for(int j=1;j<=n;j++) {
sx[j][i]=sx[j-1][i]+ax[j][i],ssx[j][i]=ssx[j-1][i]+j*ax[j][i];
sy[i][j]=sy[i][j-1]+ay[i][j],ssy[i][j]=ssy[i][j-1]+j*ay[i][j];
}
}
vector<ll> res;
for(int i=0;i<q;i++) {
res.push_back(calc(B[i]+1,R[i]+1)-calc(B[i]+1,L[i])-calc(T[i],R[i]+1)+calc(T[i],L[i]));
}
return res;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3892kb
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: 0ms
memory: 3820kb
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: 0
Wrong Answer
time: 1ms
memory: 5852kb
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 0 0 1 2 2 1 2 0 0 2
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 64ms
memory: 28048kb
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:
wrong answer 29884th lines differ - on the 1st token, expected: '65391', found: '6657755848'
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 44ms
memory: 11532kb
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 -23 -11 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 -17 15 -1 2 5 11 8 16 -22 4 12 4 9 23 1 2 5 6 4 1 4 4 3 6 4 18 32 10 2 -18 7 5 12 11 7 4 4 10 6 4 16 8 -12 8 3 3 8 21 1 2 3 6 14 21 -11 9 2 -22 2 4 16 -5 7 3 5 3 15 16 ...
result:
wrong answer 10th lines differ - on the 1st token, expected: '2', found: '-23'
Subtask #6:
score: 0
Wrong Answer
Test #42:
score: 0
Wrong Answer
time: 78ms
memory: 27832kb
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 0 0 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 1 1 1 0 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 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 ...
result:
wrong answer 4th lines differ - on the 1st token, expected: '1', found: '0'
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%