QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470378#6394. Turn on the Lightlllei#WA 1ms3872kbC++20466b2024-07-10 12:26:402024-07-10 12:26:40

Judging History

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

  • [2024-07-10 12:26:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3872kb
  • [2024-07-10 12:26:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
int find()
{
   int lst=0,l=1,r=n;
   while(l<=r){
     int mid=(l+r)/2;
     printf("? %d\n",mid);
     fflush(stdout);
     int now;
     scanf("%d",&now);
     if(now==lst) return mid;
     if(now<lst) r=mid-1;
     if(now>lst) l=mid+1;
     lst=now;
   }
  return l;
}
int main()
{
   scanf("%d",&n);
   int ans=find();
    printf("! %d\n",ans);
    fflush(stdout);
    return 0;
}
 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

3
1
1

output:

? 2
? 3
! 3

result:

ok Correct position at 3

Test #2:

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

input:

10
1
2
3
4

output:

? 5
? 8
? 9
? 10
! 11

result:

wrong answer Integer parameter [name=x] equals to 11, violates the range [1, 10]