QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106194 | #6394. Turn on the Light | 4_ss# | WA | 2ms | 3432kb | C++17 | 806b | 2023-05-16 20:37:24 | 2023-05-16 20:37:27 |
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;
for(int i=1;i<m;i++)
{
cout<<"? "<<sb[i]<<endl;
scanf("%d",&num[i]);
if(num[1]==0)
{
cout<<"! "<<sb[i]<<endl;
cout.flush();
break;
}
else if(num[1]==1)//右
sb[i+1]=(sb[i]+n)/2;
else if(num[1]==-1)//左
sb[i+1]=(sb[i]+1)/2;
if(i>=2)
{
if(num[i]==num[i-1])
{
cout<<"! "<<sb[i]<<endl;
cout.flush();
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;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3432kb
input:
3 1
output:
? 1 ? 0
result:
wrong answer Integer parameter [name=x] equals to 0, violates the range [1, 3]