QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#614084 | #8239. Mysterious Tree | klhwong# | WA | 1ms | 3616kb | C++17 | 3.1kb | 2024-10-05 15:33:52 | 2024-10-05 15:34:00 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int t, n, res, u, v, x, y;
bool flag;
string q;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> t;
while(t--) {
cin >> n;
flag = false;
for (int i = 1; i <= n; i += 2) {
if (i == n) {
q = "? " + to_string(i - 1) + " " + to_string(i) + "\n";
} else {
q = "? " + to_string(i) + " " + to_string(i + 1) + "\n";
}
cout << q;
cout.flush();
cin >> res;
if (res == 1) {
u = i;
v = i + 1;
if (i == 1) {
x = n - 1;
y = n;
} else {
x = 1;
y = 2;
}
flag = true;
break;
}
}
if (!flag) {
cout << "! 2" << "\n";
cout.flush();
} else {
q = "? " + to_string(u) + " " + to_string(x) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 0) {
q = "? " + to_string(v) + " " + to_string(x) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 0) {
cout << "! 1" << "\n";
cout.flush();
} else {
q = "? " + to_string(v) + " " + to_string(y) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 1) {
cout << "! 2" << "\n";
cout.flush();
} else {
cout << "! 1" << "\n";
cout.flush();
}
}
} else {
q = "? " + to_string(u) + " " + to_string(y) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 0) {
q = "? " + to_string(v) + " " + to_string(x) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 0) {
cout << "! 1" << "\n";
cout.flush();
} else {
q = "? " + to_string(v) + " " + to_string(y) + "\n";
cout << q;
cout.flush();
cin >> res;
if (res == 1) {
cout << "! 2" << "\n";
cout.flush();
} else {
cout << "! 1" << "\n";
cout.flush();
}
}
} else {
cout << "! 2" << "\n";
cout.flush();
}
}
}
}
cout.flush();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
input:
2 4 1 0 1 0 4 0 1 1 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 3 1 ? 3 2 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3616kb
input:
87 13 0 0 0 0 0 1 0 1 1 15 0 0 0 0 0 0 1 1 1 7 0 0 0 1 1 1 15 0 0 0 1 0 0 19 0 0 0 0 0 1 1 1 20 0 0 0 0 0 0 0 0 0 0
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 1 ? 12 1 ? 12 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 1 ? 13 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 6 7 ? 7 1 ? 7 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 7 1 ? 8 1 ! 1 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 1 ? 11 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 1...
result:
wrong answer Wrong prediction (test case 6)