QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#342871#8239. Mysterious Treeucup-team191#WA 1ms3672kbC++231.3kb2024-03-01 18:43:422024-03-01 18:43:42

Judging History

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

  • [2024-03-01 18:43:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3672kb
  • [2024-03-01 18:43:42]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int t,n;

int ask(int a,int b)
{
	cout<<"? "<<a<<' '<<b<<endl;
	int x;
	cin>>x;
	return x;
}

void solve()
{
	cin>>n;
	int gd=-1;
	for (int i=0;i<n/2;++i)
	{
		if (n%2==0 && i==n/2-1)
		{
			gd=i;
			break;
		}
		if (ask(i*2+1,i*2+2))
		{
			if (gd!=-1)
			{
				cout<<"! 1"<<endl;
				return;
			}
			gd=i;
			break;
		}
	}
	if (gd==-1)
	{
		for (int i=n-1;i>=n-3;--i)
		{
			if (ask(i,n)==0)
			{
				cout<<"! 1"<<endl;
				return;
			}
		}
		cout<<"! 2"<<endl;
		return;
	}
	else
	{
		if (gd==0)
		{
			int a=ask(1,3),b=ask(1,4),c=ask(2,3),d=ask(2,4);
			if ((a && b) || (c && d)) cout<<"! 2"<<endl;
			else cout<<"! 1"<<endl;
		}
		else
		{
			int a=ask(gd*2+1,gd*2),b=ask(gd*2+1,gd*2-1);
			int c=ask(gd*2+2,gd*2),d=ask(gd*2+2,gd*2-1);
			if ((a && b) || (c && d)) cout<<"! 2"<<endl;
			else cout<<"! 1"<<endl;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>t;
	while (t--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct (2 test cases)

Test #2:

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

input:

87
13
0
0
0
0
0
1
0
0
1
1
15
0
0
0
0
0
0
1
1
1
0
0
7
0
0
0
1
1
1
15
0
0
0
1
0
0
0
0
19
0
0
0
0
0
1
1
1
0
0
20
0
0
0
0
0
0
0
0
0
0
0
0
0
7
0
0
1
0
0
1
1
20
0
0
0
0
0
0
0
1
1
1
0
0
17
0
0
0
0
0
0
0
0
0
11
1
0
0
0
1
14
0
0
0
0
0
0
0
0
0
0
13
0
0
0
0
0
0
0
18
0
0
0
0
0
1
0
0
1
1
14
0
1
0
0
1
1
20
0
0
0
...

output:

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

result:

wrong answer Wrong prediction (test case 63)