QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404712#6394. Turn on the Lighthanmx#WA 1ms3588kbC++17673b2024-05-04 15:06:382024-05-04 15:06:38

Judging History

你现在查看的是最新测评结果

  • [2024-05-04 15:06:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-05-04 15:06:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll =long long;
int ask(ll d)
{
    cout<<"?"<<" "<<d<<endl;
    int n;
    cin>>n;
    return n;
}
void solve()
{
    int n;
    cin>>n;
    ll l=0,r=n;
    ll t=0;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        ll d=ask(mid);
        if(d==t)
        {
            cout<<"!"<<" "<<mid<<endl;
            return;
        }else  if(d>t)
        {
            l=mid+1;
        }else{
            r=mid-1;
        }
        t=d;
        //cout<<l<<" "<<r<<" "<<t<<"\n";
    }
}
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: 1ms
memory: 3588kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

10
1
2
3
4

output:

? 5
? 8
? 9
? 10

result:

wrong answer format  Unexpected end of file - token expected