QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#605099 | #8236. Snake Move | DBsoleil# | WA | 0ms | 3636kb | C++20 | 1.1kb | 2024-10-02 15:29:29 | 2024-10-02 15:29:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=300005;
int T,n,a[N],pos;
ll pre[N],suf[N],sum;
int query(int x,int y)
{
int res=0;
cout<<"? "<<x<<' '<<y<<endl;
cout.flush();
cin>>res;
return res;
}
void output(int id)
{
cout<<"! "<<id<<endl;
cout.flush();
}
int check(int x,int y)
{
int z,w;
for(int i=1;i<=n;i++) if(i!=x&&i!=y) {z=i; break;}
int f=query(y,z);
if(f)
{
for(int i=1;i<=n;i++) if(i!=x&&i!=y&&i!=z)
{
if(query(y,i)) return 2;
else return 1;
}
}
else f=query(x,z);
if(!f) return 1;
for(int i=1;i<=n;i++) if(i!=x&&i!=y&&i!=z)
{
if(query(x,i)) return 2;
else return 1;
}
return 1;
}
void solve()
{
cin>>n;
int flag=0;
for(int i=1;i<=n;i+=2)
{
int x,y,f=0;
if(i==n) x=1,y=i;
else x=i,y=i+1;
f=query(x,y);
if(!f) continue;
else {flag=0,output(check(x,y)); return;}
}
output(1);
}
int main()
{
cin>>T;
while(T--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3636kb
input:
4 5 5 3 5 3 4 3 3 3 2 4 2 ..... ..... ..... .....
output:
? 1 2 ? 2 3 ? 2 4 ! 2 ? 1 2 ? 2 3 ! 1 ? 1 2 ? 2 3 ! 1 ? 1 2 ? 2 3 ? 1 3 ! 1
result:
wrong answer 1st lines differ - expected: '293', found: '? 1 2'