QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796967#8239. Mysterious TreeUESTC_DebugSimulator#WA 1ms3656kbC++17829b2024-12-02 13:06:412024-12-02 13:06:41

Judging History

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

  • [2024-12-02 13:06:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3656kb
  • [2024-12-02 13:06:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main(){
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		int fl=-1;
		for(int i=1;i<=n/2;i++){
			cout<<"? "<<i*2-1<<" "<<i*2<<endl;
			int res;
			cin>>res;
			if(res==1){
				fl=i;
				break;
			}
		}
		if(fl==-1){
			cout<<"! 1"<<endl;
			continue;
		}
		int x=2*fl-1,y=2*fl;
		int l,r;
		if(x==1)l=3,r=4;
		else l=1,r=2;
		cout<<"? "<<x<<" "<<l<<endl;
		int res;
		cin>>res;
		if(res==1){
			cout<<"? "<<x<<" "<<r<<endl;
			cin>>res;
			if(res==1)cout<<"! 2"<<endl;
			else cout<<"! 1"<<endl;
		}
		else{
			cout<<"? "<<y<<" "<<l<<endl;
			cin>>res;
			if(res==1){
				cout<<"? "<<y<<" "<<r<<endl;
				cin>>res;
				if(res==1)cout<<"! 2"<<endl;
				else cout<<"! 1"<<endl;
			}
			else cout<<"! 1"<<endl;
		}
	}
	return 0;
}

詳細信息

Test #1:

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

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: 1ms
memory: 3656kb

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 1
? 12 1
? 12 2
! 2
? 1 2
? 3 4
? 5 6
? 7 8
? 9 10
? 11 12
? 13 14
? 13 1
? 13 2
! 2
? 1 2
? 3 4
? 5 6
! 1

result:

wrong answer Wrong prediction (test case 3)