QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695178 | #8239. Mysterious Tree | GLLF234 | WA | 1ms | 3632kb | C++20 | 1.8kb | 2024-10-31 19:28:09 | 2024-10-31 19:28:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
double a[100005];
void slove(){
int n;
cin>>n;
for(int i=1;i<=n;i+=2){
cout<<'?'<<" "<<i<<" "<<i+1<<endl;
fflush(stdout);
int x;
cin>>x;
if(x==1){
int k=i+2;
if(k>n) k%=n;
cout<<"?"<<" "<<i<<" "<<k<<endl;
fflush(stdout);
int y;
cin>>y;
if(y==1){
k=i+3;
if(k>n) k%=n;
cout<<"?"<<" "<<i<<" "<<k<<endl;
fflush(stdout);
int z;
cin>>z;
if(z==1){
cout<<"! 2"<<endl;
return ;
}
else {
cout<<"! 1"<<endl;
return ;
}
}
else{
cout<<"?"<<" "<<i+1<<" "<<k<<endl;
fflush(stdout);
int z;
cin>>z;
if(z==0){
cout<<"! 1"<<endl;
return ;
}
else{
k=i+3;
if(k>n) k=k%n;
cout<<"?"<<" "<<i+1<<" "<<k<<endl;
fflush(stdout);
int o;
cin>>o;
if(o==0){
cout<<"! 1"<<endl;
return ;
}
else{
cout<<"! 2"<<endl;
return ;
}
}
}
}
}
cout<<"! 1"<<endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin>>T;
while(T--){
slove();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3588kb
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: 3632kb
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 13 ? 12 13 ? 12 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 15 ? 13 1 ! 2 ? 1 2 ? 3 4 ? 5 6 ? 7 8
result:
wrong answer Integer 8 violates the range [1, 7] (test case 3)