QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#356109#8239. Mysterious Treeucup-team2681#WA 1ms3904kbC++231.2kb2024-03-17 15:39:372024-03-17 15:39:37

Judging History

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

  • [2024-03-17 15:39:37]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-03-17 15:39:37]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define lowbit(x) (x&-x)
using namespace std;
int n;
bool qry(int x,int y){
	printf("? %d %d",x,y);cout<<endl;
	int p;
	scanf("%d",&p);
	return p;
}
void solve(int x,int y){
	for(int i=1;i<=n;i++){
		if(i!=x&&i!=y){
			if(qry(i,x)){
				for(int j=1;j<=n;j++){
					if(j==i||j==x||j==y)continue;
					if(qry(j,x)){
						printf("! 2");
						cout<<endl;
						return;
					}
					else{
						printf("! 1");
						cout<<endl;
						return;
					}
				}
				
			}
			else{
				break;
			}
		}
	}
	swap(x,y);
	for(int i=1;i<=n;i++){
		if(i!=x&&i!=y){
			if(qry(i,x)){
				for(int j=1;j<=n;j++){
					if(j==i||j==x||j==y)continue;
					if(qry(j,x)){
						printf("! 2");
						cout<<endl;
						return;
					}
					else{
						printf("! 1");
						cout<<endl;
						return;
					}
				}
				
			}
			else{
				break;
			}
		}
	}
	printf("! 2");
	cout<<endl;
}
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i+=2){
		int tmp=i;
		if(i==n)tmp--;
		if(qry(tmp,tmp+1)){
			solve(tmp,tmp+1);
			return;
		}
	}
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

2
4
1
0
1
0
4
0
1
1
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

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
1
0
1
1
15
0
0
0
1
0
0

output:

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

result:

wrong answer Wrong prediction (test case 4)