QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333608 | #8239. Mysterious Tree | Dualqwq# | WA | 1ms | 3792kb | C++17 | 924b | 2024-02-20 10:00:20 | 2024-02-20 10:00:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n;
inline int Ask(int x,int y) {
printf("? %d %d\n",x,y);
fflush(stdout);
int res;cin >> res;return res;
}
inline void work() {
cin >> n;
for(int i = 1;i <= n / 2;i += 2) {
int v = Ask(i,i + 1);
if(v) {
int x = i,y = i + 1;
int v1 = 0,v2 = 0;
for(int j = 1;j <= n;j++)
if(j != x && j != y) {
if(!v1) v1 = j; else v2 = j;
}
int r1 = Ask(x,v1),r2 = Ask(y,v1);
if(!r1 && !r2)
{cout << "! 1" << endl;fflush(stdout);return;}
if(!r1) swap(x,y);
if(!Ask(v2,x)) { cout << "! 1" << endl;fflush(stdout);return;}
cout << "! 2" << endl;fflush(stdout);return;
}
}
int cnt = 0;
for(int i = 1;i <= 3;i++) cnt += Ask(i,n);
if(cnt == 3) cout << "! 2" << endl;
else cout << "! 1" << endl;
fflush(stdout);
}
int main() {
int T;
cin >> T;
while(T--) work();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3792kb
input:
2 4 1 0 1 0 4 0 0 0 1
output:
? 1 2 ? 1 3 ? 2 3 ? 4 2 ! 1 ? 1 2 ? 1 4 ? 2 4 ? 3 4 ! 1
result:
wrong answer Wrong prediction (test case 2)