QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#670189#8239. Mysterious Treetest123WA 1ms3692kbC++141.1kb2024-10-23 20:47:122024-10-23 20:47:12

Judging History

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

  • [2024-10-23 20:47:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3692kb
  • [2024-10-23 20:47:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int T,n; 
bool op;
int main(){
	cin>>T;
	while(T--){
		cin>>n;
		bool flg=1;
		for(int i=1;i+1<=n;i+=2){
			cout<<"? "<<i<<" "<<i+1<<endl;
			cin>>op;
			if(op){
				cout<<"? "<<i<<" "<<(i+1)%n+1<<endl;
				cin>>op;
				if(op){
					cout<<"? "<<i<<" "<<(i+2)%n+1<<endl;
					cin>>op;
					if(op){
						cout<<"! 2"<<endl;	
						flg=0;
						break;
					}else{
						cout<<"! 1"<<endl;
						flg=0;
						break;
					}
				}else{
					cout<<"? "<<i+1<<" "<<(i+1)%n+1<<endl;
					cin>>op;
					if(!op){
						cout<<"! 1"<<endl;
						flg=0;
						break;
					}else{
						cout<<"? "<<i+1<<" "<<(i+2)%n+1<<endl;
						cin>>op;
						if(!op){
							cout<<"! 1"<<endl;
							flg=0;
							break;
						}else{
							cout<<"! 2"<<endl;
							flg=0;
							break;
						}
					}
				}
			}
		}
		if(flg){
			for(int i=1;i<=3;++i){
				cout<<"? "<<n<<" "<<1<<endl;
				cin>>op;
				if(!op){			
					cout<<"! 1"<<endl;
					flg=0;
					break;
				}	
			}
			if(flg){
				cout<<"! 2"<<endl;
			}
		}
	}
	return 0;
}

詳細信息

Test #1:

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

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: 3692kb

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

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

result:

wrong answer Wrong prediction (test case 6)