QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#350128 | #8239. Mysterious Tree | mc020207# | WA | 1ms | 3624kb | C++17 | 1.5kb | 2024-03-10 14:34:45 | 2024-03-10 14:34:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = (a);i <= (b);i++)
#define Rof(i, a, b) for(int i = (a);i >= (b);i--)
int ask(int x,int y){
cout<<"? "<<x<<" "<<y<<endl;
int t;cin>>t;
return t;
}
int n;
int st[10],top;
int getn(){
For(i,1,n){
bool f=0;
For(j,1,top){
if (i==st[j]){
f=1;
break;
}
}
if (!f) return i;
}
}
void Main(){
top=0;
cin>>n;
bool f=0;
int x,y;
for (int i=1;i<=n;i+=2){
if (ask(i,i%n+1)){
x=i,y=i&n+1;
f=1;
break;
}
}
// if (n%2){
// if(ask(1,n)){
// x=1,y=n;
// f=1;
// }
// }
if (!f){
cout<<"! "<<1<<endl;
return ;
}
st[++top]=x,st[++top]=y;
int z=getn();
if (ask(x,z)){
st[++top]=z;
int w=getn();
if (ask(x,w)){
cout<<"! "<<2<<endl;
}else{
cout<<"! "<<1<<endl;
}
}else swap(x,y);
if (ask(x,z)){
st[++top]=z;
int w=getn();
if (ask(x,w)){
cout<<"! "<<2<<endl;
}else{
cout<<"! "<<1<<endl;
}
}else{
cout<<"! "<<1<<endl;
}
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T;cin>>T;
while (T--) Main();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3624kb
input:
2 4 1 1 0 4 0 1
output:
? 1 2 ? 1 2 ? 1 3 ! 1 ? 1 2 ? 1 3 ! 1 ? 1 1
result:
wrong answer Wrong prediction (test case 2)