QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343390#8239. Mysterious Tree111445#WA 1ms3752kbC++23849b2024-03-02 15:01:232024-03-02 15:01:25

Judging History

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

  • [2024-03-02 15:01:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2024-03-02 15:01:23]
  • 提交

answer

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

#define N 1000000
int i,j,k,n,m,t;

int ask(int x,int y){
	cout<<"? "<<x<<' '<<y<<endl;
	cin>>x;
	return x;
}

int NMSL(int x,int y){
	if(!ask(x,y))return 0;
	
	int i,t1=0,t2=0;
	for(i=1;i<=n;i++)if(i!=x&&i!=y){
		if(!t1)t1=i;
		else t2=i;
	}
	
	if(ask(x,t1)){
		if(ask(x,t2))return 1;
		return 0;
	}
	
	if(ask(y,t1)){
		if(ask(y,t2))return 1;
		return 0;
	}
	
	return 0;
}

int fuck(){
	for(i=2;i<=n;i+=2){
		if(ask(i-1,i)){
			if(NMSL(i-1,i))return 1;
			return 0;
		}
	}
	if(n&1){
		if(ask(n-1,n)){
			if(NMSL(n-1,n))return 1;
			return 0;
		}
	}
	return 0;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		if(fuck()){
			cout<<"! "<<2<<endl;
		}
		else cout<<"! "<<1<<endl;
	}
}

詳細信息

Test #1:

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

input:

2
4
1
1
0
1
0
4
0
1
1
1
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

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

output:

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

result:

wrong answer Too many queries , n = 7 , now_q 8 (test case 3)