QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404686 | #6394. Turn on the Light | hanmx# | WA | 1ms | 3640kb | C++23 | 672b | 2024-05-04 14:34:48 | 2024-05-04 14:34:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll ask(ll d)
{
cout<<"? "<<d<<endl;
ll n;
cin>>n;
return n;
}
void solve()
{
ll n;
cin>>n;
ll l=1,r=n;
ll t=0;
while(l<=r)
{
ll mid=(l+r)>>1;
ll d=ask(mid);
if(d==t)
{
cout<<"! "<<mid<<endl;
return;
}else if(d>t)
{
l=mid+1;
}else{
r=mid-1;
}
t=d;
//cout<<l<<" "<<r<<" "<<ls<<" "<<rs<<"\n";
}
}
int main(){
ll t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
10 1 2 3 4
output:
? 5 ? 8 ? 9 ? 10
result:
wrong answer format Unexpected end of file - token expected