QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#840880 | #9915. General Symmetry | rqoi031 | TL | 3ms | 10052kb | C++20 | 1.0kb | 2025-01-03 09:18:02 | 2025-01-03 09:18:03 |
Judging History
answer
#include<stdio.h>
#include<algorithm>
#include<bitset>
constexpr int N{200000},K{1000};
int a[N+5];
std::bitset<(N<<1)+5> f[K+5],g,h;
int l[N+5];
int main() {
int n,k;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) {
scanf("%d",a+i);
}
for(int j=0;j<=K;j++) {
for(int i=1;i<=n;i++) {
f[j].set(i,std::abs(a[i]-j)<=k);
}
}
std::fill(l+2,l+(n<<1)+1,n);
for(int i=2;i<=n<<1;i++) {
h.set(i,1);
}
for(int i=1;i<=n;i++) {
g=g>>1&f[a[i]];
g.set(i,1);
g.set(i+1,1);
auto _h(h&~g<<i);
for(int j=_h._Find_first();j<=i<<1;j=_h._Find_next(j)) {
l[j]=(i<<1)-j-1;
h.set(j,0);
}
}
for(int i=1;i<=n;i++) {
l[i<<1]=std::min(l[i<<1],(std::min(i,n-i+1)<<1)-1);
printf("%d%c",l[i<<1],i==n?'\n':' ');
}
for(int i=1;i<=n-1;i++) {
l[i<<1|1]=std::min(l[i<<1|1],std::min(i,n-i)<<1);
printf("%d%c",l[i<<1|1],i==n-1?'\n':' ');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7964kb
input:
5 0 1 2 1 2 1
output:
1 3 5 3 1 0 0 0 0
result:
ok 9 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 10052kb
input:
5 1 1 2 1 3 1
output:
1 3 5 3 1 2 2 0 0
result:
ok 9 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 8088kb
input:
10 0 1 2 3 4 500 5 501 6 499 503
output:
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0
result:
ok 19 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 10044kb
input:
10 1 1 2 3 4 500 5 501 6 499 503
output:
1 1 1 1 3 3 5 1 1 1 2 2 2 0 0 0 0 0 0
result:
ok 19 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 9984kb
input:
10 2 1 2 3 4 500 5 501 6 499 503
output:
1 3 3 1 3 5 5 3 1 1 2 2 2 0 0 0 0 0 0
result:
ok 19 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 9900kb
input:
10 10 1 2 3 4 500 5 501 6 499 503
output:
1 3 3 1 3 5 5 3 1 1 2 4 2 0 0 0 0 0 2
result:
ok 19 numbers
Test #7:
score: -100
Time Limit Exceeded
input:
100000 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...