QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#106201 | #6394. Turn on the Light | blzgods# | TL | 0ms | 0kb | C++11 | 849b | 2023-05-16 21:39:00 | 2023-05-16 21:39:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10;
int query(int x)
{
printf("? %d\n",x);scanf("%d",&x);return x;
}
void print(int x)
{
printf("! %d\n",x);
}
void solve()
{
int n;scanf("%d",&n);
int lst=0;
int l=1,r=n;
while(1)
{
int now=query(l);
if(now==lst){print(l);return ;}
l=l+1;
lst=now;
while(l<r)
{
int mid=(l+r)/2;
int now=query(mid);
if(now==lst){print(mid);return ;}
if(now>lst)
{
l=mid+1;lst=now;
}
else
{
r=mid-1;lst=now;break;
}
}
if(l==r){print(l);return ;}
}
}
int main()
{
int T=1;
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3