QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#882716#9734. Identify ChordzqiaorWA 1ms3584kbC++17780b2025-02-05 10:54:142025-02-05 10:54:16

Judging History

This is the latest submission verdict.

  • [2025-02-05 10:54:16]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3584kb
  • [2025-02-05 10:54:14]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
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-y;
	if(ask(x,y-1)==d-1){
		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;
		}
	}else l=y;
	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

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3584kb

input:

2
6
2
2
2
2
1
4
1
1
1
1
1

output:

? 1 4
? 1 5
? 1 3
? 6 4
! 2 4
? 1 3
? 1 4
? 1 2
? 1 3
! 1 3

result:

ok ok (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3584kb

input:

1000
15
5
6
6
4
1
19
5
4
4
5
-1

output:

? 1 8
? 1 9
? 1 7
? 12 8
! 5 8
? 1 10
? 1 11
? 1 11
? 14 1
! 7 1

result:

wrong answer Wrong answer n=19, actual=3-12, guessed=7-1 (test case 2)