QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#841398#9915. General Symmetryucup-team3586#TL 8ms55212kbC++231.1kb2025-01-03 18:29:222025-01-03 18:29:23

Judging History

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

  • [2025-01-03 18:29:23]
  • 评测
  • 测评结果:TL
  • 用时:8ms
  • 内存:55212kb
  • [2025-01-03 18:29:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define bi bitset<400100>
bi O[1010],Z,P,T;
int n,a[200100],m,ans[401000];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]),O[a[i]][i]=1;
    for(int i=1000;i;i--)O[i]|=O[i+1];
    for(int i=1;i<=n*2;i++){
        if(!(i&1))ans[i]=min(i/2,n+1-i/2);
        else ans[i]=min(i/2,n-i/2);
    }
    for(int i=n;i;i--){
        T[i*2+1]=T[i*2]=1;
        if(a[i]+m+1<=1000){
            P=(T&(O[a[i]+m+1]<<i));
            for(int o=P._Find_first();o<=n*2;o=P._Find_next(o))
                ans[o]=min(ans[o],o/2-i);
            T^=P;
        }
        //2i<=o
    }
    for(int i=1;i<=n;i++){
        T[i*2-1]=T[i*2]=1;
        if(a[i]+m+1<=1000){
            P=(T&(O[a[i]+m+1]<<i));
            for(int o=P._Find_first();o<=n*2;o=P._Find_next(o))
                ans[o]=min(ans[o],i-(o+1)/2);
            T^=P;
        }
        //o<=i*2
    }
    for(int i=2;i<=n*2;i+=2)printf("%d ",ans[i]*2-1);puts("");
    for(int i=3;i<n*2;i+=2)printf("%d ",ans[i]*2);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 54244kb

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

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

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: 4ms
memory: 53904kb

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: 8ms
memory: 55212kb

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

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: