QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#323875 | #8239. Mysterious Tree | ucup-team2279# | WA | 0ms | 3576kb | C++14 | 679b | 2024-02-10 13:57:17 | 2024-02-10 13:57:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin>>n;
auto ask=[&](int x,int y){
cout<<"? "<<x<<" "<<y<<endl;
int res;cin>>res;
return res;
};
for(int i=2;i<=n;i+=2) if(ask(i,i-1)){
int u=i==2?3:1,v=1;
while(v==u||v==i||v==i-1) v++;
if(ask(u,i)){
cout<<"! "<<ask(v,i)+1<<endl;
return;
}else if(ask(u,i-1)){
cout<<"! "<<ask(v,i-1)+1<<endl;
return;
}else{
cout<<"! 1"<<endl;
return;
}
}
if(n&1){
for(int i:{1,2,3}) if(!ask(n,i)){
cout<<"! 1"<<endl;
return;
}
cout<<"! 2"<<endl;
}else cout<<"! 1"<<endl;
}
int main(){
int t;
cin>>t;
while(t--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
input:
2 4 1 1
output:
? 2 1 ? 3 2 ! ? 4 2
result:
wrong answer format Expected integer, but "?" found (test case 1)