QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#709240#8239. Mysterious TreekonghaojieWA 0ms3652kbC++17986b2024-11-04 13:14:012024-11-04 13:14:02

Judging History

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

  • [2024-11-04 13:14:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-11-04 13:14:01]
  • 提交

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;
	while(1){
		if(v>n) v=1;
		if(u>n) break;
		cout<<"? "<<u<<" "<<v<<endl;
		cin>>res;
		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: 0ms
memory: 3652kb

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: 3592kb

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)