QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343299 | #8239. Mysterious Tree | zzuqy# | WA | 1ms | 3892kb | C++14 | 1.1kb | 2024-03-02 13:38:54 | 2024-03-02 13:38:56 |
Judging History
answer
#include <bits/stdc++.h>
int ask(int a, int b) {
int o;
printf("? %d %d\n", a, b);
fflush(stdout);
scanf("%d", &o);
return o;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, o;
scanf("%d", &n);
int p, q, cnt = 0;
for (int i = 1; i <= n; i += 2) {
if (i + 1 <= n) {
o = ask(i, i + 1);
} else {
o = ask(i, 1);
}
if (o) {
cnt++;
p = i;
q = (i == n) ? 1 : (i + 1);
}
}
if (cnt == 0) {
printf("! 1");
} else if (cnt > 1) {
printf("! 1");
} else {
int oo = 0, e;
for (int i = 1; oo < 2; i++) {
if (i != p && i != q) {
if (ask(p, i)) {
e = i;
oo++;
} else {
oo += 100;
}
}
}
if (oo == 2) {
printf("! 2");
} else {
oo = 0;
for (int i = 1; oo < 2; i++) {
if (i != p && i != q) {
if (ask(q, i)) {
oo++;
} else {
oo += 100;
}
}
}
if (oo == 2) {
printf("! 2");
} else {
printf("! 1");
}
}
}
puts("");
fflush(stdout);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3892kb
input:
2 4 1 1 4 0 1 1 1
output:
? 1 2 ? 3 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: 3744kb
input:
87 13 0 0 0 0 0 1 0 0 1 1 15 0 0 0 0 0 0 1 0 1 1 7 0 0 0 1 1 1 15 0 0 0 1 1 0 0 1 19 0 0 0 0 0 1 0 0 0 0 1 1 20 0 0 0 0 0 0 0 0 0 0 7 0 0 1 0 0 1 1 20 0 0 0 0 0 0 0 1 0 0 1 1 17 0 0 0 0 0 0 0 0 0 11 1 1 0 0 0 0 14 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 18 0 0 0 0 0 1 0 0 0 0 1 1 14 0 1 0 0 0 0 0 0 1 1 20 0 ...
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 1 ? 11 1 ? 12 1 ? 12 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 15 1 ? 13 1 ? 13 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 1 ? 7 2 ? 7 3 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 15 1 ! 1 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 15 16 ? 17...
result:
wrong answer Wrong prediction (test case 68)