QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106192 | #6394. Turn on the Light | 4_ss# | WA | 3ms | 3444kb | C++17 | 798b | 2023-05-16 20:30:28 | 2023-05-16 20:30:31 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int m=41;
const int N=1e6+10;
bool light[N];
signed main()
{
int n;
cin>>n;
int num[m];
int sb[n+1];
for(int i=0;i<n+1;i++) sb[i]=0;
sb[1]=(1+n)/2;
for(int i=1;i<m;i++)
{
cout<<"? "<<sb[i]<<endl;
scanf("%d",&num[i]);
if(num[1]==0)
{
cout<<"! "<<sb[i]<<endl;
break;
}
else if(num[1]==1)//右
sb[i+1]=(sb[i]+n)/2+1;
else if(num[1]==-1)//左
sb[i+1]=(sb[i]+1)/2-1;
if(i>=2)
{
if(num[i]==num[i-1])
{
cout<<"! "<<sb[i]<<endl;
break;
}
else if(num[i]==num[i-1]+1)
{
sb[i+1]=(sb[i]+n)/2+1;
}
else if(num[i]==num[i-1]-1)
{
sb[i+1]=(sb[i]+sb[i-1])/2-1;
}
}
cout.flush();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 3444kb
input:
3 1
output:
? 2 ? 0
result:
wrong answer Integer parameter [name=x] equals to 0, violates the range [1, 3]