QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710518#6394. Turn on the Light_sexyboyWA 1ms3960kbC++14537b2024-11-04 20:13:272024-11-04 20:13:27

Judging History

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

  • [2024-11-04 20:13:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3960kb
  • [2024-11-04 20:13:27]
  • 提交

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(r!=l){
        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: 3960kb

input:

3
1

output:

? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3

output:

? 5
? 8
? 9
! 10

result:

wrong answer Wrong answer, more than 1 possible light!