QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#882770#9734. Identify ChordzqiaorCompile Error//C++17763b2025-02-05 11:09:582025-02-05 11:09:58

Judging History

This is the latest submission verdict.

  • [2025-02-05 11:09:58]
  • Judged
  • [2025-02-05 11:09:58]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int T,n,k,d,X,x,y,l,r,mid,flag;
int ask(int x,int y){
	if(flag)x=n-x%n,y=n-y%n;
	return cout<<"? "<<(x-1)%n+1<<" "<<(y-1)%n+1<<endl,cin>>X,X;
}
void get(int x,int y){
	if(flag)x=n-x%n,y=n-y%n;
	cout<<"! "<<(x-1)%n+1<<" "<<(y-1)%n+1<<endl,cin>>X;
}
void solve(){
	cin>>n,k=n/2,x=1,y=k+1,flag=0;
	while(ask(x,y)==k)if(n%2==0)x++,y++;else (x+k<y?x:y)++;
	d=X;
	if(ask(x,y+1)==d-1)flag=1,x=n-x,y=n+n-y;
	l=x,r=y;
	while(l<=r){
		mid=l+r>>1;
		if(ask(x,mid)==d-y+mid)r=mid-1;
		else l=mid+1;
	}
	d-=y-l+1;
	if(ask(n+x-d,l)==1)get(n+x-d,l);
	else get(x+d,l);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>T;
	while(T--)solve();
	return 0;
}

Details

cc1plus: error: ‘::main’ must return ‘int’