QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613108 | #8239. Mysterious Tree | fosov# | WA | 1ms | 3648kb | C++14 | 1.4kb | 2024-10-05 13:35:12 | 2024-10-05 13:35:17 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define M 100010
bool qry(int u, int v) {
cout << "? " << u << " " << v << '\n';
cout.flush();
bool res; cin >> res;
return res;
}
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while (t --) {
int n; cin >> n;
int r0 = n-1, r1 = n-1;
int ecnt = 0;
for (int i = 1; i < n; i += 2) {
bool he = qry(i, i+1);
if (he) ++ ecnt, r0 = i, r1 = i+1;
}
if (ecnt > 1) {
cout << "! 1" << '\n';
cout.flush();
continue;
}
if (r0 == r1) {
bool star = qry(r0, 1) && qry(r0, 2) && qry(r0, 3);
cout << (star ? "! 2" : "! 1" ) << '\n';
cout.flush();
} else {
int op1 = r0 == 1 ? 3 : 1;
int op2 = r0 == 1 ? 4 : 2;
bool star = 0;
if (qry(r0, op1)) {
star = qry(r0, op2);
} else {
star = qry(r1, op1) && qry(r1, op2);
}
cout << (star ? "! 2" : "! 1" ) << '\n';
cout.flush();
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
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: 3648kb
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 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 1 ! 1
result:
wrong answer Wrong prediction (test case 3)