QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323875#8239. Mysterious Treeucup-team2279#WA 0ms3576kbC++14679b2024-02-10 13:57:172024-02-10 13:57:18

Judging History

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

  • [2024-02-10 13:57:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3576kb
  • [2024-02-10 13:57:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void solve(){
	int n;
	cin>>n;
	auto ask=[&](int x,int y){
		cout<<"? "<<x<<" "<<y<<endl;
		int res;cin>>res;
		return res;
	};
	for(int i=2;i<=n;i+=2) if(ask(i,i-1)){
		int u=i==2?3:1,v=1;
		while(v==u||v==i||v==i-1) v++;
		if(ask(u,i)){
			cout<<"! "<<ask(v,i)+1<<endl;
			return;
		}else if(ask(u,i-1)){
			cout<<"! "<<ask(v,i-1)+1<<endl;
			return;
		}else{
			cout<<"! 1"<<endl;
			return;
		}
	}
	if(n&1){
		for(int i:{1,2,3}) if(!ask(n,i)){
			cout<<"! 1"<<endl;
			return;
		}
		cout<<"! 2"<<endl;
	}else cout<<"! 1"<<endl;
}
int main(){
	int t;
	cin>>t;
	while(t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

2
4
1
1

output:

? 2 1
? 3 2
! ? 4 2

result:

wrong answer format  Expected integer, but "?" found (test case 1)