QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#582292#8239. Mysterious TreeargtargTL 0ms0kbC++201.2kb2024-09-22 15:57:402024-09-22 15:57:41

Judging History

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

  • [2024-09-22 15:57:41]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-09-22 15:57:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T = 1;
	cin >> T;
	while (T--)solve();
	return 0;
}
const int mod = 998244353;

void solve() {
	int n;
	cin >> n;
	auto co = [&](int x, int y)->void {
		cout << "? " << x << ' ' << y << endl;
	};
	for (int i = 1; i <= n; i+=2) {
		int x = i, y = i + 1;
		if (x == n)y = 1;
		co(x, y);
		int t;
		cin >> t;
		if (t == 1) {
			int num = 0;
			int nx = 0;
			for (int j = 1; j <= n; j++) {
				if (j == x || j == y)continue;
				if (num == 0) {
					co(x, j);
					num++;
					int a;
					cin >> a;
					co(y, j);
					int b;
					cin >> b;
					if (a == 1) {
						nx = x;
					}
					else if(b==1){
						nx = y;
					}
					else {
						cout << "! " << 1 << endl;
						return;
					}
				}
				else {
					co(nx, j);
					int t;
					cin >> t;
					if (t == 1) {
						cout << "! 2\n";
					}
					else {
						cout << "! 1\n";
					}
					return;
				}
			}
			return;
		}
	}
	cout << "! 1\n";

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

2
4

output:


result: