QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#348105 | #8239. Mysterious Tree | Freeuni1# | WA | 1ms | 3624kb | C++14 | 909b | 2024-03-09 16:58:28 | 2024-03-09 16:58:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
bool ask(int a, int b) {
cout <<"? "<< a << " " << b << endl;
int p;
cin >> p;
return p;
}
int main() {
int t;
cin >> t;
while (t --) {
int n;
cin >> n;
int a = -1, b = -1;
for (int i = 1; i <= n; i += 2) {
int A = i;
int B = (i % n) + 1;
if (ask(A, B)) {
a = A;
b = B;
break;
}
}
if (a == -1) {
cout << "! 1" << endl;
continue;
}
int c = (a % n) + 1;
if (c == b) {
c = (c + 1) % n;
}
if (ask(a, c)) {
c = (c % n) + 1;
if (c == b) {
c = (c % n) + 1;
}
if (ask(a, c)) cout << "! 2" << endl;
else cout << "! 1" << endl;
} else {
if (ask(b, c)) {
c = (c % n) + 1;
if (c == b) {
c = (c % n) + 1;
}
if (ask(b, c)) cout << "! 2" << endl;
else cout << "! 1" << endl;
} else cout << "! 1" << endl;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
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: 3624kb
input:
87 13 0 0 0 0 0 1
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 0
result:
wrong answer Integer 0 violates the range [1, 13] (test case 1)