QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710528#6394. Turn on the Light_sexyboyWA 1ms3912kbC++14534b2024-11-04 20:15:512024-11-04 20:15:51

Judging History

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

  • [2024-11-04 20:15:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3912kb
  • [2024-11-04 20:15:51]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,res,l,r,mid,tmp,tt;
int main(){
    cin>>n;r=n;l=1;
    while(1){
        mid=(l+r)/2;
        printf("? %d\n",mid);
        cout.flush();
        scanf("%d",&tt);
        if(tt==tmp){
            printf("! %d\n",mid);
            cout.flush();
            return 0;
        }
        else if(tt==tmp+1){
            tmp=tt;l=mid+1;
        }
        else{
            tmp=tt;r=mid-1;
        }
    }
    printf("! %d\n",r);
    cout.flush();
    return 0;
}

詳細信息

Test #1:

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

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4
4

output:

? 5
? 8
? 9
? 10
? 10
! 10

result:

wrong answer Wrong answer, more than 1 possible light!