QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#710528 | #6394. Turn on the Light | _sexyboy | WA | 1ms | 3912kb | C++14 | 534b | 2024-11-04 20:15:51 | 2024-11-04 20:15:51 |
Judging History
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!