QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697727#6429. Let's Play Curling552Hz#WA 1ms5632kbC++141.8kb2024-11-01 15:30:332024-11-01 15:30:33

Judging History

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

  • [2024-11-01 15:30:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5632kb
  • [2024-11-01 15:30:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=200010;
const ll mod=998244353;
int n,m;
ll a[N],b[N];
void solve(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];a[i]*=2;
	}
	std::vector<ll> q;
	for(int i=1;i<=m;i++){
		cin>>b[i];b[i]*=2;
		q.push_back(b[i]);
	}
	ll ans=0;
	sort(q.begin(),q.end());
	q.push_back(1e17);
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
	for(int i=1;i<=n;i++){
		ll pos=a[i];
		ll w=lower_bound(q.begin(),q.end(),pos)-q.begin();
		ll dis=1e18;
		dis=min(dis,q[w]-pos);
		if(w!=0){
			w--;
		}
		dis=min(dis,pos-q[w]);
		cout<<dis<<" ";
		int r=0,l=0;
		if(dis==0){
			continue;
		}
		for(int j=20;j>=0;j--){
			if((r+(1<<j))+i>n){
				continue;
			}
			if(a[(r+(1<<j))+i]-a[i]<dis){
				r+=(1<<j);
			}
		}
		for(int j=20;j>=0;j--){
			if(i-(l+(1<<j))<1){
				continue;
			}
			if(a[i]-a[i-(l+(1<<j))]<dis){
				l+=(1<<j);
			}
		}
		r=r+i;
		l=i-l;
		ans=max(ans,1ll*(r-l+1));
	}
	for(int i=1;i<n;i++){
		ll pos=(a[i]+a[i+1])/2;
		ll w=lower_bound(q.begin(),q.end(),pos)-q.begin();
		ll dis=1e18;
		dis=min(dis,q[w]-pos);
		if(w!=0){
			w--;
		}
		dis=min(dis,pos-q[w]);
		cout<<dis<<" ";
		int r=0,l=0;
		if(dis==0){
			continue;
		}
		for(int j=20;j>=0;j--){
			if((r+(1<<j))+i>n){
				continue;
			}
			if(a[(r+(1<<j))+i]-a[i]<dis){
				r+=(1<<j);
			}
		}
		for(int j=20;j>=0;j--){
			if(i-(l+(1<<j))<1){
				continue;
			}
			if(a[i]-a[i-(l+(1<<j))]<dis){
				l+=(1<<j);
			}
		}
		r=r+i;
		l=i-l;
		ans=max(ans,1ll*(r-l+1));
	}
	if(ans==0){
		cout<<"Impossible"<<endl;
	}else{
		cout<<ans<<endl;
	}
	//cout<<ans<<endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _=1;
	cin>>_;
	while(_--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5632kb

input:

3
2 2
2 3
1 4
6 5
2 5 3 7 1 7
3 4 3 1 10
1 1
7
7

output:

2 2 3 2
0 2 0 2 6 6 1 1 0 4 6 3
0 Impossible

result:

wrong answer 1st lines differ - expected: '2', found: '2 2 3 2'