QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235941#6394. Turn on the LightTimMCBen#WA 1ms3628kbC++20623b2023-11-03 13:40:452023-11-03 13:40:45

Judging History

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

  • [2023-11-03 13:40:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2023-11-03 13:40:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<"? 1"<<endl;
    int x;
    cin>>x;
    if(x==0)
    {
        cout<<"! 1"<<endl;
        return 0;
    }

    int l=2,r=n;
    while(l<=r)
    {
        int mid=(l+r)/2;
        cout<<"? "<<mid<<endl;
        int cur;
        cin>>cur;
        if(cur>x)
        {
            l=mid+1;
            x=cur;
        }else if(cur<x)
        {
            r=mid-1;
            x=cur;
        }else
        {
            x=cur;
            cout<<"! "<<mid<<endl;
            break;
        }

    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

3
1
2
2

output:

? 1
? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3532kb

input:

10
1
0
1
2
3

output:

? 1
? 6
? 3
? 4
? 5

result:

wrong answer format  Unexpected end of file - token expected