QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796967 | #8239. Mysterious Tree | UESTC_DebugSimulator# | WA | 1ms | 3656kb | C++17 | 829b | 2024-12-02 13:06:41 | 2024-12-02 13:06:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int T;
cin>>T;
while(T--){
int n;
cin>>n;
int fl=-1;
for(int i=1;i<=n/2;i++){
cout<<"? "<<i*2-1<<" "<<i*2<<endl;
int res;
cin>>res;
if(res==1){
fl=i;
break;
}
}
if(fl==-1){
cout<<"! 1"<<endl;
continue;
}
int x=2*fl-1,y=2*fl;
int l,r;
if(x==1)l=3,r=4;
else l=1,r=2;
cout<<"? "<<x<<" "<<l<<endl;
int res;
cin>>res;
if(res==1){
cout<<"? "<<x<<" "<<r<<endl;
cin>>res;
if(res==1)cout<<"! 2"<<endl;
else cout<<"! 1"<<endl;
}
else{
cout<<"? "<<y<<" "<<l<<endl;
cin>>res;
if(res==1){
cout<<"? "<<y<<" "<<r<<endl;
cin>>res;
if(res==1)cout<<"! 2"<<endl;
else cout<<"! 1"<<endl;
}
else cout<<"! 1"<<endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 3656kb
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)