QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710509#6394. Turn on the Light_sexyboyWA 1ms3884kbC++14527b2024-11-04 20:11:492024-11-04 20:11:50

Judging History

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

  • [2024-11-04 20:11:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3884kb
  • [2024-11-04 20:11:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,res,l,r,mid,tmp,tt;
int main(){
    cin>>n;r=n;l=1;mid=(l+r)/2;
    while(r!=l){
        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: 3884kb

input:

3
1

output:

? 2
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
1

output:

? 5
? 5
! 5

result:

wrong answer Wrong answer, more than 1 possible light!