QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#840899#9915. General Symmetryrqoi031TL 1076ms21440kbC++201.1kb2025-01-03 09:33:182025-01-03 09:33:19

Judging History

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

  • [2025-01-03 09:33:19]
  • 评测
  • 测评结果:TL
  • 用时:1076ms
  • 内存:21440kb
  • [2025-01-03 09:33:18]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
#include<bitset>
constexpr int N{200000},K{1000};
int a[N+5];
std::bitset<N+5> f[K+5],g,h;
int l[(N<<1)+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;i++) {
        h.set(i,1);
    }
    for(int i=1;i<=n;i++) {
        g>>=1;
        g&=f[a[i]];
        g.set(i,1);
        g.set(i+1,1);
        h>>=1;
        h.set(n,1);
        auto _h(h&~g);
        for(int j=_h._Find_first();j<=i;j=_h._Find_next(j)) {
            l[i+j]=i-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: 3ms
memory: 7988kb

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: 3ms
memory: 7988kb

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: 0ms
memory: 7868kb

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: 0ms
memory: 9772kb

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: 7864kb

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: 9752kb

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: 0
Accepted
time: 989ms
memory: 21440kb

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:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...

result:

ok 199999 numbers

Test #8:

score: 0
Accepted
time: 1000ms
memory: 21292kb

input:

100000 0
2 1 2 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 1 2 1 2 2 1 1 1 2 2 2 2 2 1 1 2 2 1 2 1 2 2 1 1 1 2 2 2 1 2 1 2 2 1 2 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 1 1 2 1 2 2 1 2 1 1 2 2 1 1 1 2 1 2 1 2 2 2 1 2 1 1 1 2 1 2 1 2 1 1 2 1 1 2 2 1 1 2 2 1 1 2 1 2 1 1 1 1 2 2 2 2 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2...

output:

1 3 3 1 3 11 3 1 3 17 3 1 3 9 3 1 5 1 1 3 5 5 3 1 1 1 7 1 1 3 9 3 1 1 1 1 1 3 11 3 1 1 1 7 1 1 5 1 3 7 3 1 1 3 5 5 3 1 1 1 5 1 13 1 5 1 1 1 1 3 3 1 1 3 3 1 3 3 1 1 3 3 1 1 1 1 1 5 1 3 5 5 3 1 9 1 3 3 1 9 1 3 5 9 5 3 1 1 7 1 1 1 1 1 1 1 1 1 1 3 7 3 1 3 3 1 1 3 3 1 1 3 5 9 5 3 1 3 13 3 1 3 9 3 1 5 1 1...

result:

ok 199999 numbers

Test #9:

score: 0
Accepted
time: 1011ms
memory: 21308kb

input:

100000 1
2 2 1 2 1 2 1 1 2 1 1 2 1 2 2 2 1 1 1 1 2 2 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 2 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 1 1 1 2 1 1 1 2 1 2 2 1 2 2 2 2 1 2 2 1 2 2 2 1 1 1 2 1 1 1 2 1 2 2 1 2 2 1 1 1 1 2 2 2 1 1 2 2 2 1 2 1 2 2 2 1 1 1 1 2 2 1 1 1 1 2 1 2 2 2 2 1 1 1 2 1 2 1 1 2 2 1 1 2 2 1 2...

output:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...

result:

ok 199999 numbers

Test #10:

score: 0
Accepted
time: 1076ms
memory: 21432kb

input:

100000 1000
732 864 923 542 711 842 80 128 371 633 258 351 763 694 384 254 328 863 981 613 558 596 470 246 925 811 893 9 872 685 177 696 665 294 972 124 915 480 67 558 391 433 538 415 832 840 206 489 895 964 952 891 671 373 257 528 337 497 296 929 154 465 150 783 305 849 107 178 417 51 877 508 13 81...

output:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...

result:

ok 199999 numbers

Test #11:

score: -100
Time Limit Exceeded

input:

200000 1
2 2 2 1 2 1 1 2 2 2 2 2 1 2 2 1 1 1 2 1 1 1 2 2 1 2 1 2 2 1 1 2 2 1 1 2 1 2 1 1 2 1 1 2 1 2 1 2 1 1 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 2 1 2 2 2 2 2 2 1 1 1 2 2 1 2 1 2 2 2 1 1 2 2 1 2 2 1 1 2 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1 1 2 2 2 2 2 2 1 1 1 2 2 2 1 2 2 1 2 1 1 1...

output:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...

result: