QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407469 | #6394. Turn on the Light | nageing# | TL | 0ms | 0kb | C++20 | 642b | 2024-05-08 19:20:41 | 2024-05-08 19:20:43 |
answer
#include <bits/stdc++.h>
using namespace std;
int query(int x) {
cout << "? " << x << '\n';
int res;
cin >> res;
return res;
}
void solve() {
int n;
cin >> n;
int l = 0, r = n + 1;
while (n -- && 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3