QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#882761#9734. Identify ChordzqiaorWA 1ms3456kbC++17756b2025-02-05 11:08:102025-02-05 11:08:29

Judging History

This is the latest submission verdict.

  • [2025-02-05 11:08:29]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3456kb
  • [2025-02-05 11:08:10]
  • 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+n-y;
	l=(x-1)%n+1,r=(y-1)%n+1;
	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;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok ok (2 test cases)

Test #2:

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

input:

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

output:

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

result:

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