QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581481 | #6394. Turn on the Light | wsxcb# | WA | 0ms | 3612kb | C++17 | 669b | 2024-09-22 13:01:20 | 2024-09-22 13:01:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void pri(int x) {
cout << "? " << x << endl;
}
void pri_(int x) {
cout << "! " << x << endl;
}
void solve() {
int n;
cin >> n;
pri(1);
int x;
cin >> x;
int pre = x;
if (x == 0) {
pri_(1);
} else {
int le = 2, ri = n;
while (le <= ri) {
int mid = (le + ri) >> 1;
pri(mid);
cin >> x;
if (x > pre) {
le = mid + 1;
} else if (x < pre) {
ri = mid - 1;
} else {
pri_(mid);
return;
}
pre = x;
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
10 1 0 1 2 3
output:
? 1 ? 6 ? 3 ? 4 ? 5
result:
wrong answer format Unexpected end of file - token expected