QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#848346#9915. General SymmetrywdnmdwrnmmpRE 1ms5976kbC++141.7kb2025-01-08 19:46:462025-01-08 19:46:47

Judging History

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

  • [2025-01-08 19:46:47]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5976kb
  • [2025-01-08 19:46:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define pb emplace_back
#define fi first
#define se second
using vi=vector<int>;
using pi=pair<int,int>;

template<typename T> bool chmin(T &x,const T &y){
	if(y<x){
		x=y;
		return true;
	}
	return false;
}
template<typename T> bool chmax(T &x,const T &y){
	if(y>x){
		x=y;
		return true;
	}
	return false;
}

const int N=2e5+5, A=1005, B=256, NB=800;

using bs=bitset<N>;

int n, k, a[N];
bs cur, f[NB], g[A];

signed main(){
	ios::sync_with_stdio(0);cin.tie(0);
	
	cin>>n>>k;
	rep(i,1,n){
		cin>>a[i];
	}
	rep(i,1,n){
		cur = cur>>1 & g[a[i]];
		cur[i]=1;
		if(i>1) cur[i-1]=(abs(a[i]-a[i-1])<=k);
		if(i%B==0){
			f[i]=cur;
		}
		rep(j, max(1,a[i]-k), min(A-1,a[i]+k)){
			g[j][i]=1;
		}
	}
	rep(i,1,n){
		int le=(i+B-1)/B, ri=n/B;
		int ans=0;
		if(le<=ri){
			while(le<ri){
				int mid=(le+ri+1)/2;
				int r=mid*B, l=i*2-r;
				if(l>0 && f[r/B][l]){
					le=mid;
				}
				else{
					ri=mid-1;
				}
			}
			ans=max(0, le*B-B-i);
		}
		while(i+ans<n && i-ans>1 && abs(a[i+ans+1]-a[i-ans-1])<=k){
			ans++;
		}
		cout<< ans*2+1 <<' ';
	}
	cout<<'\n';
	rep(i,2,n){
		int le=(i+B)/B, ri=n/B;
		int ans=0;
		if(le<=ri){
			while(le<ri){
				int mid=(le+ri+1)/2;
				int r=mid*B, l=i*2-1-r;
				if(l>0 && f[r/B][l]){
					le=mid;
				}
				else{
					ri=mid-1;
				}
			}
			ans=max(0, le*B-B-i);
		}
		// cout<<"?"<<i<<' '<<ans<<endl;
		while(i+ans<=n && i-1-ans>=1 && abs(a[i+ans]-a[i-ans-1])<=k){
			ans++;
		}
		cout<< ans*2 <<' ';
	}
	cout<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3808kb

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: 1ms
memory: 3768kb

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: 1ms
memory: 3776kb

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: 1ms
memory: 3740kb

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

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: 1ms
memory: 5976kb

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
Runtime Error

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: