QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#840880#9915. General Symmetryrqoi031TL 3ms10052kbC++201.0kb2025-01-03 09:18:022025-01-03 09:18:03

Judging History

你现在查看的是最新测评结果

  • [2025-01-03 09:18:03]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:10052kb
  • [2025-01-03 09:18:02]
  • 提交

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;
}

详细

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...

output:


result: