QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#395409#8239. Mysterious TreeQian#WA 1ms3948kbC++14877b2024-04-21 14:17:092024-04-21 14:17:11

Judging History

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

  • [2024-04-21 14:17:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3948kb
  • [2024-04-21 14:17:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n;
bool ask(int x,int y){
	printf("? %d %d\n",x+1,y+1);
	fflush(stdout);
	int p;
	scanf("%d",&p);
	fflush(stdout);
	return p;
}
int main(){
	int T;scanf("%d",&T);
	while(T--){
	    fflush(stdout);
		int n;scanf("%d",&n);
		fflush(stdout);
		bool flag=0;
		for(int i=0;i<n;i+=2)
		  if(ask(i,i+1)){
		  	flag=1;
		  	if(ask(i,(i+2)%n)){
		  		if(ask(i,(i+3)%n)){
		  			printf("! 2\n");
				  }
				else printf("! 1\n"); 
			}
			else if(ask(i+1,(i+2)%n)){
		  		if(ask(i+1,(i+3)%n)){
		  			printf("! 2\n");
				  }
				else printf("! 1\n"); 
			}
			else printf("! 1\n");
			break;
		  }
		if(flag)continue;
		if(n&1){
			if(ask(n,1)){
				if(ask(n,2)){
					printf("! 2\n");
				}
				else printf("! 1\n");
			}
			else printf("! 1\n");
		}
	}
	return 0;
} 

详细

Test #1:

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

input:

2
4
1
0
1
0
4
0
1
1
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
0
1
1
15
0
0
0
0
0
0
1
1
1
7
0
0
0

output:

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

result:

wrong answer Integer 8 violates the range [1, 7] (test case 3)