QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#523734#8239. Mysterious TreeasitshouldbeWA 1ms3696kbC++141.7kb2024-08-18 17:11:232024-08-18 17:11:23

Judging History

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

  • [2024-08-18 17:11:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3696kb
  • [2024-08-18 17:11:23]
  • 提交

answer

#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#define x first
#define y second
//#define endl '\n'
#define pi acos(-1.0)
using namespace std;
typedef pair<int, int> PII;
typedef pair<double, int> PDI;
typedef pair<PII, int> PIII;
typedef pair<PII, char> PIIC;
typedef long long LL;
int dx[] = {1, 0, 0, -1, -1, -1, 1, 1}, dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
int mou[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int N = 1e3 + 10, M = 110, mod = 998244353, INF = 0x3f3f3f3f;
const double eps = 1e-8;
int n,m,t;

int input(int a,int b)
{
	cout<<"? "<<a<<" "<<b<<endl;
	//fflush(stdout);
	int c;cin>>c;
	return c;
}

void output(int a)
{
	cout<<"! "<<a<<endl;
	//fflush(stdout);	
}

void solve()
{
	cin>>n;
	int pos=-1,cnt=0;
	for(int i=1;i+1<=n;i+=2)
	{
		int x=input(i,i+1);
		if(x)
		{
			cnt++;
			pos=i;
		}
	}
	if(n%2)
	{
		int x=input(n-1,n);
		if(x)
		{
			cnt++;
			pos=n-1;
		}
	}
	if(cnt!=1)
	{
		output(1);
		return;
	}
	int a=pos,b=pos+1;
	int x=input(a,b%n+1),y=input(b,b%n+1);
	if(!x&&!y) output(1);
	else if(x)
	{
		int z=input(a,a==1?n:a-1);
		if(z) output(2);
		else output(1);
	}
	else if(y)
	{
		int z=input(b,a==1?n:a-1);
		if(z) output(2);
		else output(1);
	}
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0),cout.precision(10);
    // freopen("in.in","r",stdin);
    // freopen("test.out","w",stdout);  
    t=1; cin >> t;
    while (t--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
1
1
4
0
1
1
0
1

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
1

output:

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

result:

wrong answer Wrong prediction (test case 1)