QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#470378 | #6394. Turn on the Light | lllei# | WA | 1ms | 3872kb | C++20 | 466b | 2024-07-10 12:26:40 | 2024-07-10 12:26:40 |
Judging History
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;
}
詳細信息
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]