QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#544349#8239. Mysterious Treeenar#WA 2ms3560kbC++201.6kb2024-09-02 15:25:082024-09-02 15:25:08

Judging History

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

  • [2024-09-02 15:25:08]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3560kb
  • [2024-09-02 15:25:08]
  • 提交

answer

#include <bits/stdc++.h>
using i64 = long long;

int ask(int x, int y) {
	std::cout << "? " << x << ' ' << y << std::endl;
	int res;
	std::cin >> res;
	return res;
}

void solve() {
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int>> res;
	for(int i = 0; i < n; i += 2) {
		int x = i + 1, y = (i + 1) % n + 1;
		if(res.size() > 2) break;
		if(ask(x, y)) {
			res.push_back({x, y});
		}
	}
	if(n % 2 == 0) {
		if(res.size() != 1) {
			std::cout << "! 1" << std::endl;
		} else {
			auto [x, y] = res.front();
			int res1 = ask(x, y % n + 1);
			int res2 = ask(y, y % n + 1);
			if(res1 == 1 && ask(x, (y + 1) % n + 1)) {
				std::cout << "! 2" << std::endl;
			} else if(res2 == 1 && ask(y, (y + 1) % n + 1)) {
				std::cout << "! 2" << std::endl;
			} else {
				std::cout << "! 1" << std::endl;
			}
		}
	} else if(n % 2 == 1) {
		if(res.size() == 1) {
			auto [x, y] = res.front();
			int res1 = ask(x, y % n + 1);
			int res2 = ask(y, y % n + 1);
			if(res1 == 1 && ask(x, (y + 1) % n + 1)) {
				std::cout << "! 2" << std::endl;
			} else if(res2 == 1 && ask(y, (y + 1) % n + 1)) {
				std::cout << "! 2" << std::endl;
			} else {
				std::cout << "! 1" << std::endl;
			}
		} else if(res.size() == 2) {
			auto [x, y] = res.front();
			if(ask(x, (y + 1) % n + 1)) {
				std::cout << "! 2" << std::endl;
			} else {
				std::cout << "! 1" << std::endl;
			}
		} else {
			std::cout << "! 1" << std::endl;
		}
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int T;
	std::cin >> T;
	while(T--) {
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

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: 2ms
memory: 3512kb

input:

87
13
0
0
0
0
0
1
0
0
1
1
15
0
0
0
0
0
0
1
0
1
0
1
7
0
0
0
1
1
0
1
15
0
0
0
1
1
0
0
1
19
0
0
0
0
0
1
0
0
0
0
1
0
1
20
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
0
0
1
0
1
17
0
0
0
0
0
0
0
0
0
11
1
1
0
0
0
0
0
14
0
0
0
0
0
0
0
13
0
0
0
0
0
0
0
18
0
0
0
0
0
1
0
0
0
0
1
1
14
0
1
0
0
0
0
0
0...

output:

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

result:

wrong answer Wrong prediction (test case 19)