QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371552#6394. Turn on the Lighthuangxi#TL 0ms0kbC++17653b2024-03-30 13:57:542024-03-30 13:57:55

Judging History

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

  • [2024-03-30 13:57:55]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-03-30 13:57:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef long long LL;
const int N=1e3+10,M=510;
int n,m;
pair<int,int>a[N],b[N];
int query(int x){
    int cur;
    cout<<"? "<<x;
    cout.flush();
    cin>>cur;
    return cur;
}

int main() {
    scanf("%d",&n);
    int l=1,r=n;
    int pre=0;
    while(l<=r){
        int mid=l+r>>1;
        int cur=query(mid);

        if(cur==pre){
            cout<<"! "<<mid;
            cout.flush();
            break;
        }else if(cur>pre){
             l=mid+1;

        }else{
            r=mid-1;
        }
        pre=cur;
    }


}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:

? 2

result: