QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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)