QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528278 | #6394. Turn on the Light | lsflsf2023# | WA | 1ms | 3688kb | C++14 | 750b | 2024-08-23 12:24:17 | 2024-08-23 12:24:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int ask(int x){
cout << "? " << x << endl;
cout.flush();
cin >> x;
return x;
}
int main()
{
int n;
cin >> n;
int last = 0;
int x = ask(1);
if(x == last){
cout << "! " << 1 << "\n";
return 0;
}
last = x;
int l = 2 , r = n;
while(l < r){
int mid = (l + r) >> 1;
x = ask(mid);
if(x == last){
cout << "! " << mid << endl;
return 0;
}
if(x > last) {
l = mid + 1;
last = x;
}else {
r = mid - 1;
last = x;
}
}
cout << "! " << r << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
3 1 2
output:
? 1 ? 2 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3620kb
input:
10 1 0 1 2
output:
? 1 ? 6 ? 3 ? 4 ! 5
result:
wrong answer Wrong answer, more than 1 possible light!