QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#324198#8239. Mysterious Treeucup-team484#TL 0ms0kbC++17754b2024-02-10 16:54:022024-02-10 16:54:02

Judging History

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

  • [2024-02-10 16:54:02]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-02-10 16:54:02]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;

int ok(int i, int j, int n) {
	while (j > n)
		j -= n;
	cout << "? " << i << " " << j << endl;
	int t; cin >> t;
	return t;
}

void solve() {
	int n; cin >> n;
	for (int i = 1; i <= n; i += 2) {
		if (!ok(i, i + 1, n))
			continue;
		int deg = ok(i, i + 2, n);
		if (deg == 1)
			deg += ok(i, i + 3, n);
		if (deg == 2 || deg == 0 && ok(i + 1, i + 2, n) && ok(i + 1, i + 3, n)) {
			cout << "! 2" << endl;
			return;
		}
		return;
	}
	cout << "! 1" << endl;
}

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

详细

Test #1:

score: 0
Time Limit Exceeded

input:

2
4
1
0
1
0

output:

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

result: