QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586626 | #8239. Mysterious Tree | SLF666# | WA | 1ms | 3628kb | C++17 | 1.1kb | 2024-09-24 14:44:01 | 2024-09-24 14:44:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
const int N = 2e5 + 5;
int query(int u,int v){
cout<<"? "<<u<<" "<<v<<endl;
cout.flush();
int ans;
cin>>ans;
return ans;
}
void solve(){
int n;
cin>>n;
int u=-1,v;
for(int i=1;i+1<=n;i+=2){
int ans = query(i, i+1);
if(ans == 1){
u = i;
v = i + 1;
break;
}
}
if(u == -1){
cout<<"! 1\n";
return;
}
int w;
for(int i=1;i<=n;i++){
w = i;
if(w != u && w != v)break;
}
int ww;
for(int i=1;i<=n;i++){
ww = i;
if(ww != u && ww != v && ww != w)break;
}
int ans = query(u, w);
if(ans == 1){
ans = query(u, ww);
if(ans == 1){//xing
cout<<"! 2\n";
}
else cout<<"! 1\n";
}
else {
ans = query(v, w);
if(ans == 1){
ans = query(v, ww);
if(ans == 1){
cout<<"! 2\n";
}
else cout<<"! 1\n";
}
else cout<<"! 1\n";
}
}
signed main(){
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
int t = 1;
cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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: 3628kb
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
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 ! 1
result:
wrong answer Wrong prediction (test case 3)