QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#341690 | #8239. Mysterious Tree | OobugoO | WA | 0ms | 3712kb | C++20 | 2.0kb | 2024-02-29 20:35:20 | 2024-02-29 20:35:20 |
Judging History
answer
#include <bits/stdc++.h>
#define OobugoO_IOS std::ios::sync_with_stdio(false), std::cin.tie(nullptr)
typedef long long ll;
void solve() {
int n;
std::cin >> n;
int num = 0;
int p;
for (int i = 1; i < n; i += 2) {
std::cout << "? " << i << " " << i + 1 << "\n";
int f;
std::cin >> f;
if (f) {
num ++;
p = i;
}
}
if ((n & 1) && num == 0) {
int f1, f2, f3;
std::cout << "? " << n << " " << 1 << "\n";
std::cin >> f1;
std::cout << "? " << n << " " << 2 << "\n";
std::cin >> f2;
std::cout << "? " << n << " " << 3 << "\n";
std::cin >> f3;
if (f1 && f2 && f3) {
std::cout << "! " << 1 << "\n";
} else {
std::cout << "! " << 0 << "\n";
}
} else if (num == 0 || num >= 2) {
std::cout << "! " << 1 << "\n";
} else {
int f1;
std::cout << "? " << p << " " << ((p + 1) % n) + 1 << "\n";
std::cin >> f1;
if (f1) {
int f2;
std::cout << "? " << p << " " << ((p + 2) % n) + 1 << "\n";
std::cin >> f2;
if (f2) {
std::cout << "! " << 1 << "\n";
} else {
std::cout << "! " << 0 << "\n";
}
} else {
int f2, f3;
std::cout << "? " << p + 1 << " " << ((p + 1) % n) + 1 << "\n";
std::cin >> f2;
std::cout << "? " << p + 1 << " " << ((p + 2) % n) + 1 << "\n";
std::cin >> f3;
if (f2 && f3) {
std::cout << "! " << 1 << "\n";
} else {
std::cout << "! " << 0 << "\n";
}
}
}
}
int main() {
#ifdef Onlion_Judge
freopen("IO/input.in", "r", stdin);
freopen("IO/output.out", "w", stdout);
#endif
// OobugoO_IOS;
int t = 1;
std::cin >> t;
while(t--) {
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3712kb
input:
2 4 1 1 4 0 1 1 1
output:
? 1 2 ? 3 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 3 2 ! 1
result:
wrong answer Wrong prediction (test case 2)