QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#310199 | #6394. Turn on the Light | PlentyOfPenalty# | WA | 0ms | 3632kb | C++20 | 419b | 2024-01-21 08:25:13 | 2024-01-21 08:25:13 |
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;
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: 0ms
memory: 3632kb
input:
3 1 2
output:
? 1 ? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
10 1 2 3 4
output:
? 1 ? 5 ? 6 ? 8 ! 8
result:
wrong answer Wrong answer, more than 1 possible light!