QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#450571 | #8239. Mysterious Tree | liqingyang# | WA | 1ms | 3588kb | C++17 | 743b | 2024-06-22 15:47:43 | 2024-06-22 15:47:43 |
Judging History
answer
#include<iostream>
using namespace std;
int T,n,ans=0;
inline bool query(int x,int y)
{
cout<<"? "<<x<<" "<<y<<endl;
bool z;
cin>>z;
return z;
}
inline void judge(int x,int y)
{
if(ans||!x)
{
return;
}
int cnt=bool(y);
for(int i=1;cnt<2&&i<=n;i++)
{
if(i==x||i==y)
{
continue;
}
if(!query(x,i))
{
if(cnt>=2)
{
ans=1;
}
return;
}
cnt++;
}
ans=2;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--)
{
cin>>n;
int p=0,q=0;
for(int i=1;i<n;i+=2)
{
if(query(i,i+1))
{
p=i,q=i+1;
break;
}
}
p=(!p&&(n&1))?n:p;
ans=0,judge(p,q),judge(q,p);
cout<<"! "<<max(1,ans)<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3588kb
input:
2 4 1 0 1
output:
? 1 2 ? 1 3 ? 2 3 ! 2
result:
wrong answer Wrong prediction (test case 1)