QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686494#6394. Turn on the Lightlibantian#TL 0ms0kbC++23601b2024-10-29 13:50:172024-10-29 13:50:18

Judging History

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

  • [2024-10-29 13:50:18]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-29 13:50:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()

void solve(int l,int r,int y){
    int x;
    printf("? %d\n",r);
    scanf("%d",&x);
    if (x==y) {printf("! %d\n",r); exit(0);}
    y=x;
    int mid=l+r>>1;
    printf("? %d\n",mid);
    scanf("%d",&x);
    if (x==y) {printf("! %d\n",mid); exit(0);}
    if (x==y+1) solve(l,mid-1,x); else solve(mid+1,r,x);
}
signed main(){
    int n;
    scanf("%d",&n);
    solve(1,n,0);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:


result: