QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709237 | #8239. Mysterious Tree | konghaojie | WA | 1ms | 3588kb | C++17 | 1009b | 2024-11-04 13:11:48 | 2024-11-04 13:11:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define endl '\n'
void solve(){
int n;cin>>n;
int u=1,v=2;
int res,cnt=n/2+3;
while(1){
if(v>n) v=1;
cout<<"? "<<u<<" "<<v<<endl;
cin>>res;
cnt--;
if(cnt==0) break;
if(res==1){
break;
}
u+=2,v+=2;
}
if(res==0){
cout<<"! 1"<<endl;
return;
}
int x=u-1;
if(x<1) x=n;
cout<<"? "<<u<<" "<<x<<endl;
cin>>res;
if(res==1){
int y=x-1;
if(y<1) y=n;
cout<<"? "<<u<<" "<<y<<endl;
cin>>res;
if(res==1){
cout<<"! 2"<<endl;
}else{
cout<<"! 1"<<endl;
}
}else{
cout<<"? "<<v<<" "<<x<<endl;
cin>>res;
if(res==0){
cout<<"! 1"<<endl;
}else{
int y=x-1;
if(y<1) y=n;
cout<<"? "<<u<<" "<<y<<endl;
cin>>res;
if(res==1){
cout<<"! 2"<<endl;
}else{
cout<<"! 1"<<endl;
}
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 4 1 0 0 4 0 1 1 1
output:
? 1 2 ? 1 4 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 3 2 ? 3 1 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3588kb
input:
87 13 0 0 0 0 0 1 0 1 0
output:
? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 11 10 ? 12 10 ? 11 9 ! 1
result:
wrong answer Wrong prediction (test case 1)