QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712017#8239. Mysterious TreeKafuuChinocpp#WA 1ms3900kbC++141.1kb2024-11-05 14:18:312024-11-05 14:18:32

Judging History

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

  • [2024-11-05 14:18:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3900kb
  • [2024-11-05 14:18:31]
  • 提交

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), fflush(stdout);
		else printf("? %d %d\n",i,i-1), fflush(stdout);
		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); fflush(stdout);
						cin>>res[cnt++];
					}
					if(cnt==2){
						if(res[0]&&res[1]) printf("! 2\n"), fflush(stdout);
						else printf("! 1\n"), fflush(stdout);
						flag=1;
						break;
					}
				}
			}
			else{
				int res[2]={0};
				printf("? %d 1\n",n); fflush(stdout); cin>>res[0];
				printf("? %d 2\n",n); fflush(stdout); cin>>res[1];
				if(res[0]&&res[1]) printf("! 2\n"),  fflush(stdout);
				else printf("! 1\n"),  fflush(stdout);
				flag=1;
				break;
			}
			break;
		}
	}
	if(!flag) printf("! 1\n"), fflush(stdout);
}

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: 100
Accepted
time: 1ms
memory: 3900kb

input:

2
4
1
0
0
4
0
1
1
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
0
0

output:

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

result:

wrong answer Wrong prediction (test case 1)