QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712008#8239. Mysterious TreeKafuuChinocpp#TL 0ms0kbC++14944b2024-11-05 14:16:202024-11-05 14:16:22

Judging History

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

  • [2024-11-05 14:16:22]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-05 14:16:20]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int N=3e5+10;
int T,n; 

void solve(){
	cin>>n;
	int flag=0;
	for(int i=1;i<=n;i+=2){
		if(i!=n) printf("? %d %d\n",i,i+1);
		else printf("? %d %d\n",i,i-1);
		int ans;
		cin>>ans;
		if(ans){
			if(i!=n){
				int res[2]={0}, cnt=0;
				for(int j=1;j<=n;j++){
					if(j!=i&&j!=i+1){
						printf("? %d %d\n",i,j);
						cin>>res[cnt++];
					}
					if(cnt==2){
						if(res[0]&&res[1]) printf("! 2\n");
						else printf("! 1\n");
						flag=1;
						break;
					}
				}
			}
			else{
				int res[2]={0};
				printf("? %d 1\n",n); cin>>res[0];
				printf("? %d 2\n",n); cin>>res[1];
				if(res[0]&&res[1]) printf("! 2\n");
				else printf("! 1\n");
				flag=1;
				break;
			}
			break;
		}
	}
	if(!flag) printf("! 1\n");
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>T;
	while(T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2
4

output:


result: