QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343383 | #8239. Mysterious Tree | 111445# | WA | 1ms | 3564kb | C++23 | 768b | 2024-03-02 14:56:40 | 2024-03-02 14:56:41 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 1000000
int i,j,k,n,m,t;
int ask(int x,int y){
cout<<"? "<<x<<' '<<y<<endl;
cin>>x;
return x;
}
int chk(int x,int y){
if(!ask(x,y))return 0;
int i,t1=0,t2=0;
for(i=1;i<=n;i++)if(i!=x&&i!=y){
if(!t1)t1=i;
else t2=i;
}
if(ask(x,t1)){
if(ask(x,t2))return 1;
return 0;
}
if(ask(y,t1)){
if(ask(y,t2))return 1;
return 0;
}
return 0;
}
int fuck(){
for(i=1;i<=n;i+=2){
if(chk(i,i+1))return 1;
}
if(n&1){
if(chk(n-1,n))return 1;
}
return 0;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>t;
while(t--){
cin>>n;
if(fuck()){
cout<<"! "<<2<<endl;
}
else cout<<"! "<<1<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3564kb
input:
2 4 1 0 1 0 1
output:
? 1 2 ? 1 3 ? 2 3 ? 2 4 ? 3 4 ? 3 1
result:
wrong answer Too many queries , n = 4 , now_q 6 (test case 1)