QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#404676 | #6394. Turn on the Light | hanmx# | WA | 0ms | 3656kb | C++23 | 658b | 2024-05-04 14:13:54 | 2024-05-04 14:13:54 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll ask(ll d)
{
cout<<"? "<<d<<endl;
ll n;
cin>>n;
return n;
}
void solve()
{
ll n;
cin>>n;
ll l=1,r=n;
ll ls=0,rs=0;
while(l<=r)
{
ll mid=(l+r)>>1;
ll d=ask(mid);
if(d==ls-rs)
{
cout<<"! "<<mid<<endl;
return;
}else if(d>ls-rs)
{
ls++;
l=mid+1;
}else{
rs++;
r=mid-1;
}
}
}
int main(){
ll t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3572kb
input:
10 1 2 3 4
output:
? 5 ? 8 ? 9 ? 10
result:
wrong answer format Unexpected end of file - token expected