QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251954#6394. Turn on the Lightucup-team1074TL 0ms0kbC++171.3kb2023-11-15 13:41:472023-11-15 13:41:47

Judging History

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

  • [2023-11-15 13:41:47]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-11-15 13:41:47]
  • 提交

answer

#include<iostream>
#include<math.h>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<queue>
#include<string.h>
#include<stack>
#define ll long long
using namespace std;
int a[100010];
int b[100010];

void solve() 
{
	int n;
    cin>>n;
    int l=1,r=n;
    int res1=0;
    int res2=0;
    int len=0;
    int ans[50];
    while(1)
    {
        int mid =(l+r)>>1;
        cout<<"? "<<mid;
        ++len;
        cin>>ans[len];
        if(len==1)
        {
            if(ans[len]==0)
            {
                cout<<"! "<<mid;
                break;
            }
            else if(ans[len]>0)
            {
                l=mid+1;
            }
            else 
            {
                r=mid-1;
            }
            continue;
        }
        if(ans[len]==ans[len-1])
        {
            cout<<"! "<<mid;
            break;

        }
            
        else if(ans[len]>ans[len-1])
        {
            l=mid+1;
        }
        else
        {
            r=mid-1;
        }
    }


}  

int main()
{
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t;
    t=1;
    while(t>0)
    {
        t--;
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:


result: