QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#507826 | #8239. Mysterious Tree | He2717970784 | WA | 1ms | 3732kb | C++17 | 1.7kb | 2024-08-06 21:25:54 | 2024-08-06 21:25:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n = 0;
cin >> n;
for(int i = 1;i <= n;i += 2){
int x = min(i,n - 1),y = min(i + 1,n);
cout << "? " << x << ' ' << y << endl;
cout.flush();
int op = 0;
cin >> op;
if(!op){
continue;
}
vector<int>v;
for(int k = 1;k <= 4;k++){
if((k != x) && (k != y)){
v.push_back(k);
}
}
cout << "? " << x << ' ' << v[0] << endl;
cout.flush();
cin >> op;
if(op){
cout << "? " << x << ' ' << v[1] << endl;
cout.flush();
cin >> op;
if(op){
cout << "! 2" << endl;
cout.flush();
return;
}
else{
cout << "! 1" << endl;
cout.flush();
return;
}
}
else{
cout << "? " << y << ' ' << v[0] << endl;
cout.flush();
cin >> op;
if(op){
cout << "? " << y << ' ' << v[1] << endl;
cout.flush();
cin >> op;
if(op){
cout << "! 2" << endl;
cout.flush();
return;
}
else{
cout << "! 1" << endl;
cout.flush();
return;
}
}
}
}
cout << "! 1" << endl;
cout.flush();
return;
}
int main(){
int t = 0;
cin >> t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
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: 3732kb
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 1 0 1 1 15 0 0 0 1 0 0 1 1 0 19 0 0 0 0 0 1 1 1 20 0 0 0 0 0 0 0 0 0 0 7 0 0 1 0 1 1 20 0 0 0 0 0 0 0 1 1 1 17 0 0 0 0 0 0 0 0 0 11 1 0 0 1 0 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 7 ? 6 1 ? 7 1 ? 7 2 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 7 1 ? 8 1 ? 9 10 ? 9 1 ? 9 2 ! 1 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 1 ? 11 2 ! 2 ? 1 2 ? 3...
result:
wrong answer Too many queries , n = 11 , now_q 10 (test case 10)