QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#581814 | #8239. Mysterious Tree | 333zhan | WA | 0ms | 3568kb | C++20 | 1.4kb | 2024-09-22 14:15:54 | 2024-09-22 14:16:02 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
int ask (int x, int y) {
cout << "? " << x << " " << y << endl;
int ans;
cin >> ans;
return ans;
}
void solve () {
int n;
cin >> n;
int ax = -1, ay;
for (int i = 1; i <= (n + 1) / 2; i += 2) {
int x = i;
int y = n & 1 && i == n ? 1 : i + 1;
if (ask (x, y)) {
ax = x;
ay = y;
break;
}
}
if (ax == -1) {
cout << "! 1" << endl;
return;
}
int az;
int ans1, ans2;
vector <bool> ok (n + 1);
for (int i = 1; i <= n; i ++) {
if (i != ax && i != ay) {
ans1 = ask (ax, i);
ans2 = ask (ay, i);
az = i;
if (! ans1 && ! ans2) {
cout << "! 1" << endl;
return;
} else {
break;
}
}
}
for (int i = 1; i <= n; i ++) {
if (i != ax && i != ay && i != az) {
if (ask (ans1 ? ax : ay, i)) {
cout << "! 2" << endl;
} else {
cout << "! 1" << endl;
}
return;
}
}
}
signed main () {
ios::sync_with_stdio (false);
cin.tie (nullptr);
int T = 1;
cin >> T;
while (T --) {
solve ();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3568kb
input:
2 4 1 0 1 0 4 0
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ! 1 ? 1 2 ! 1
result:
wrong answer Wrong prediction (test case 2)