QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#882675#9734. Identify ChordzqiaorWA 1ms3712kbC++17666b2025-02-05 10:39:292025-02-05 10:39:29

Judging History

This is the latest submission verdict.

  • [2025-02-05 10:39:29]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-02-05 10:39:29]
  • Submitted

answer

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
6
2
2
1
0
0
1
-1

output:

? 1 4
? 1 5
? 1 2
? 1 1
? 1 1
? 2 1
! 2 1

result:

wrong answer Wrong answer n=6, actual=2-4, guessed=2-1 (test case 1)