QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#407472 | #6394. Turn on the Light | nageing# | WA | 1ms | 3604kb | C++20 | 628b | 2024-05-08 19:25:43 | 2024-05-08 19:25:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int query(int x) {
cout << "? " << x << endl;
int res;
cin >> res;
return res;
}
void solve() {
int n;
cin >> n;
int l = 0, r = n + 1;
while (l < r) {
int mid = l + r >> 1;
int x = query(mid);
if (x > 0) {
l = mid + 1;
} else {
r = mid;
}
}
cout << "! " << l - 1 << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.flush();
int t;
t = 1;
while (t --) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3592kb
input:
3 1 1
output:
? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3604kb
input:
10 1 2 3
output:
? 5 ? 8 ? 10 ! 10
result:
wrong answer Wrong answer, more than 1 possible light!