QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#833294 | #9240. Mosaic | hansiyuan | 0 | 80ms | 28444kb | C++17 | 2.1kb | 2024-12-26 16:50:10 | 2024-12-26 16:50:11 |
Judging History
answer
#include "mosaic.h"
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define vi vector<int>
const int N=2e5+5;
vector<lol> ans;
int n,Q;
int a0[N],a1[N],b0[N],b1[N];
int a[N<<1];
int s[N<<1];
lol s1[N<<1],s2[N<<1];
lol get0(int l,int r){
return s[r]-s[l-1];
}
lol get1(int l,int r){
return (s1[r]-s1[l-1])-get0(l,r)*(l-1);
}
lol get2(int l,int r){
return (s2[l]-s2[r+1])-get0(l,r)*(n-3+n-2-r);
}
lol work(int r,int c){
if(r<=0 || c<=0) return 0;
// cout<<r<<' '<<c<<endl;
if(r<=c)
return get0(n-3+1,n-3+c-r)*r+get1(n-3-r+2,n-3)+get2(n-3+c-r+1,n-3+c);
return get0(n-3-(r-c)+1,n-3)*c+get1(n-3-c+1,n-3-(r-c))+get2(n-3+1,n-3+c);
}
vector<lol> mosaic(vi X,vi Y,vi U,vi D,vi L,vi R){
n = X.size();
Q = U.size();
a0[0] = b0[0] = Y[0];
a1[0] = Y[1];
b1[0] = X[1];
for(int i=1;i<n;i++){
a0[i] = X[i];
a1[i] = !(a1[i-1]|a0[i]);
b0[i] = Y[i];
b1[i] = !(b1[i-1]|b0[i]);
}
a[n-3+1] = !(a1[2]|b1[2]);
for(int i=n-3;i>=1;i--){
a[i] = !(b1[n-3-i+3]|a[i+1]);
}
for(int i=n-3+1;i<=n-3+n-2;i++){
a[i] = !(a[i-1]|a1[i-(n-3)+1]);
}
a0[0] = a0[1] = a1[0] = a1[1] = 0;
for(int i=1;i<=n;i++){
a0[i]+=a0[i-1]; a1[i]+=a1[i-1];
b0[i]+=b0[i-1]; b1[i]+=b1[i-1];
}
// for(int i=1;i<=n-3+n-2;i++) printf("%d",a[i]); puts("");
for(int i=1;i<=n-3+n-2;i++)
s[i] = s[i-1]+a[i];
for(int i=1;i<=n-3+n-2;i++)
s1[i] = s1[i-1]+1ll*a[i]*i;
for(int i=n-3+n-2;i>=1;i--)
s2[i] = s2[i+1]+1ll*a[i]*(n-3+n-2-i+1);
for(int i=0;i<Q;i++){
lol res=0;
if(U[i]==0) res += a0[R[i]]-(L[i]==0? 0:a0[L[i]-1]);
if(U[i]<=1) res += a1[R[i]]-(L[i]==0? 0:a1[L[i]-1]);
if(L[i]==0) res += b0[D[i]]-(U[i]==0? 0:b0[U[i]-1]);
if(L[i]<=1) res += b1[D[i]]-(U[i]==0? 0:b1[U[i]-1]);
// cout<<res<<endl;
res += work(D[i]-1,R[i]-1);
res -= work(U[i]-2,R[i]-1);
res -= work(D[i]-1,L[i]-2);
res += work(U[i]-2,L[i]-2);
ans.push_back(res);
}
return ans;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 9880kb
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 32687 32687 32687 32687 32687 32687 32687 32687 32687 32687
result:
wrong answer 3rd lines differ - on the 1st token, expected: '0', found: '32687'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 63ms
memory: 28444kb
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 2210 132110 22036 105836 45191 144168 35165 88467 24088 23177 109895 111508 22254 39828 61771 94346 116336 108213 123502 69557 84505 2297 108812 97420 40575 97235 48897 98655 64973 8246 100817 38957 100565 21387 42808 13584 28336 93597 18163 12068 50319 122693 926...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '1314', found: '2210'
Subtask #4:
score: 0
Skipped
Dependency #2:
0%
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 43ms
memory: 16636kb
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 12 2 8 2 10 13 5 2 12 4 1 0 4 14 4 2 32 10 3 5 6 6 3 16 19 5 11 6 13 11 12 5 7 3 6 12 6 4 6 12 15 24 2 5 3 0 18 3 2 16 6 7 23 -2 4 11 7 6 1 4 10 4 6 4 16 32 10 1 13 8 3 12 11 7 4 4 10 6 4 15 8 11 5 2 4 8 21 1 2 3 6 14 19 14 5 1 3 2 5 17 20 0 2 5 3 13 16 6 36 5 7 7...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '14', found: '12'
Subtask #6:
score: 0
Wrong Answer
Test #42:
score: 0
Wrong Answer
time: 80ms
memory: 28160kb
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 -61517 1 0 1 0 104664 0 -177769 14537 64425 1 1 -88539 70890 0 82138 1 1 -116453 0 1 1 1 0 0 61707 0 0 0 1 -144909 0 1 0 1 -49368 1 1 42312 1 1 0 64205 0 0 0 -174843 1 1 0 1 0 0 0 23195 0 0 -55443 0 2113 -20126 1 0 0 0 -9048 1 0 0 0 -64954 54292 -91776 12441 -9802...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '0', found: '-61517'
Subtask #7:
score: 0
Skipped
Dependency #3:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%