QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#402872#8239. Mysterious Treezhi0929WA 1ms3560kbC++14811b2024-05-01 17:03:522024-05-01 17:03:53

Judging History

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

  • [2024-05-01 17:03:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3560kb
  • [2024-05-01 17:03:52]
  • 提交

answer

#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<bitset>
#include<iomanip>
#include<iostream>
#include<algorithm>
//#pragma GCC optimize("O0")
using namespace std;
#define int long long
signed main(){
	int N;cin>>N;
	while(N--){
	int n;cin>>n;int x;int a;
	for(a=1;a<n;a++){
	cout<<"? "<<a<<" "<<a+1<<endl;
    fflush(stdout);
	cin>>x;
	if(x)break;
	}int x1=-1,x2=-1;int x3=0,x4=0;
	for(int b=1;b<=n;b++){
	if(b==a||b==a+1)continue;
	cout<<"? "<<b<<" "<<a+1<<endl;
    fflush(stdout);
	if(x1==-1)cin>>x1;
	else cin>>x2;
	if(x2!=-1)break;}
	if(a==1){cout<<"? 1 3"<<endl;fflush(stdout);cin>>x3;cout<<"? 1 4"<<endl;fflush(stdout);cin>>x4;}
	if((x1&&x2)||(x3&&x4))cout<<"! 2"<<endl;
	else cout<<"! 1"<<endl;
    fflush(stdout);}}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
0
0
0
0
0

output:

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

result:

wrong answer Too many queries , n = 13 , now_q 11 (test case 1)