QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310200 | #6394. Turn on the Light | PlentyOfPenalty# | WA | 1ms | 3644kb | C++20 | 421b | 2024-01-21 08:27:29 | 2024-01-21 08:27:29 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
int query(int x)
{
cout<<"? "<<x<<endl;
int f;
cin>>f;
return f;
}
int main()
{
int n;
cin>>n;
int l=1,r=n,pre=0;
while(l<r)
{
int mid=(l+r+1)>>1;
int g=query(l);
if(g==pre)
{
r=l;break;
}
int f=query(mid);
if(f==pre+2)l=mid+1;
else if(f==pre)++l,r=mid-1;
else{l=r=mid;break;}
}
cout<<"! "<<l<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3644kb
input:
3 1 2
output:
? 1 ? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
10 1 0 1 0
output:
? 1 ? 6 ? 2 ? 4 ! 3
result:
ok Correct position at 3
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3640kb
input:
9 1 2 3 2
output:
? 1 ? 5 ? 6 ? 8 ! 9
result:
wrong answer Wrong favorite light!