QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#402961#8239. Mysterious Treezhi0929WA 1ms3636kbC++141.4kb2024-05-01 18:53:562024-05-01 18:53:57

Judging History

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

  • [2024-05-01 18:53:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2024-05-01 18:53:56]
  • 提交

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
#define double long double
const int maxn=3e5+10;
int arr[maxn]={0};
int sum[maxn]={0};
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
	int N;cin>>N;
	while(N--){
	int n;cin>>n;int x;int a;
	for(a=1;a<n;a+=2){
	cout<<"? "<<a<<" "<<a+1<<endl;
	cin>>x;
	cout.flush();
	if(x)break;
	}if(a==n){cout<<"? "<<n-1<<" "<<n<<endl;cout.flush();cin>>x;
	if(x==0){cout<<"! 1"<<endl;continue;}
	int t1=-1,t2=-1;cout<<"? 1 "<<n<<endl;cout.flush();cin>>t1;
	cout<<"? 2 "<<n<<endl;cout.flush();cin>>t2;
	if(t1&&t2)cout<<"! 2"<<endl;
	else cout<<"! 1"<<endl;
	continue;}
	if(a==n+1){cout<<"! 1"<<endl;
	continue;}
	int x1=-1,x2=-1;int x3=-1,x4=-1;
	for(int b=1;b<n;b++){
	if(b==a||b==a+1)continue;
	cout<<"? "<<b<<" "<<a+1<<endl;	cout.flush();
	cin>>x1;
	cout<<"? "<<b<<" "<<a<<endl;	cout.flush();
	cin>>x2;
	if(x1==0&&x2==0){cout<<"! 2"<<endl;continue;}
	for(int c=b+1;c<=n;c++){
	if(c==a||c==a+1){continue;}
	if(x1)cout<<"? "<<c<<" "<<a+1<<endl;
	else cout<<"? "<<c<<" "<<a<<endl;
	cout.flush();
	cin>>x3;
	if(x3)cout<<"! 2"<<endl;
	else cout<<"! 1"<<endl;
	break;}
	break;}}
	}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

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

output:

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

result:

wrong answer Wrong prediction (test case 4)