QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882665#9734. Identify ChordzqiaorWA 1ms3712kbC++17666b2025-02-05 10:36:042025-02-05 10:36:05

Judging History

This is the latest submission verdict.

  • [2025-02-05 10:36:05]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3712kb
  • [2025-02-05 10:36:04]
  • 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)r=mid-1;
		else l=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;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok ok (2 test cases)

Test #2:

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

input:

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

output:

? 1 8
? 1 9
? 1 4
? 1 6
? 1 7
? 1 8
? 1 8
? 12 8
! 5 8
? 1 10
? 1 11
? 10 15
? 10 18
? 10 19
? 10 1
? 10 1
? 6 1
! 14 1

result:

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