QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709237#8239. Mysterious TreekonghaojieWA 1ms3588kbC++171009b2024-11-04 13:11:482024-11-04 13:11:49

Judging History

你现在查看的是最新测评结果

  • [2024-11-04 13:11:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-11-04 13:11:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define endl '\n'
void solve(){
	int n;cin>>n;
	int u=1,v=2;
	int res,cnt=n/2+3;
	while(1){
		if(v>n) v=1;
		cout<<"? "<<u<<" "<<v<<endl;
		cin>>res;
		cnt--;
		if(cnt==0) break;
		if(res==1){
			break;
		}
		u+=2,v+=2;
	}
	if(res==0){
		cout<<"! 1"<<endl;
		return;
	}
	int x=u-1;
	if(x<1) x=n;
	cout<<"? "<<u<<" "<<x<<endl;
	cin>>res;
	if(res==1){
		int y=x-1;
		if(y<1) y=n;
		cout<<"? "<<u<<" "<<y<<endl;
		cin>>res;
		if(res==1){
			cout<<"! 2"<<endl;
		}else{
			cout<<"! 1"<<endl;
		}
	}else{
		cout<<"? "<<v<<" "<<x<<endl;
		cin>>res;
		if(res==0){
			cout<<"! 1"<<endl;
		}else{
			int y=x-1;
			if(y<1) y=n;
			cout<<"? "<<u<<" "<<y<<endl;
			cin>>res;
			if(res==1){
				cout<<"! 2"<<endl;
			}else{
				cout<<"! 1"<<endl;
			}
		}
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

详细

Test #1:

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

input:

2
4
1
0
0
4
0
1
1
1

output:

? 1 2
? 1 4
? 2 4
! 1
? 1 2
? 3 4
? 3 2
? 3 1
! 2

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
0
1
0

output:

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

result:

wrong answer Wrong prediction (test case 1)