QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#710509 | #6394. Turn on the Light | _sexyboy | WA | 1ms | 3884kb | C++14 | 527b | 2024-11-04 20:11:49 | 2024-11-04 20:11:50 |
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;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;
}
Details
Tip: Click on the bar to expand more detailed information
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!