QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#613136 | #8239. Mysterious Tree | fosov# | WA | 0ms | 3576kb | C++14 | 1.4kb | 2024-10-05 13:36:59 | 2024-10-05 13:37:16 |
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-1; 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();
}
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
2 4 1 0 1 0 4 0 1 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ! 1 ? 1 2 ? 3 1 ? 3 2 ? 3 3
result:
wrong answer u != v (test case 2)