QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#235941 | #6394. Turn on the Light | TimMCBen# | WA | 1ms | 3628kb | C++20 | 623b | 2023-11-03 13:40:45 | 2023-11-03 13:40:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
cout<<"? 1"<<endl;
int x;
cin>>x;
if(x==0)
{
cout<<"! 1"<<endl;
return 0;
}
int l=2,r=n;
while(l<=r)
{
int mid=(l+r)/2;
cout<<"? "<<mid<<endl;
int cur;
cin>>cur;
if(cur>x)
{
l=mid+1;
x=cur;
}else if(cur<x)
{
r=mid-1;
x=cur;
}else
{
x=cur;
cout<<"! "<<mid<<endl;
break;
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3532kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected