QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528267 | #6394. Turn on the Light | megumi# | WA | 1ms | 3724kb | C++14 | 935b | 2024-08-23 12:16:31 | 2024-08-23 12:16:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9')
f = (c == '-') ? -1 : 1, c = getchar();
while (c >= '0' && c <= '9')
x = x * 10 + c - 48, c = getchar();
return f * x;
}
signed main() {
int n, l = 1, r, ans = 0, x, last = 0;
cin >> n, r = n;
while (l <= r) {
cout << "? " << l << endl;
int y;
cin >> y;
if (y == last) {
cout << "! " << l << endl;
return 0;
}
last = y;
int mid = (l + r) >> 1;
cout << "? " << mid << endl;
cin >> x;
if (x == last) {
cout << "! " << mid << endl;
return 0;
}
if (x == last - 1)
r = mid - 1;
else
l = mid + 1;
last = x;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
3 1 2 2
output:
? 1 ? 2 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3724kb
input:
10 1 2 3 4 5 5
output:
? 1 ? 5 ? 6 ? 8 ? 9 ? 9 ! 9
result:
wrong answer Wrong favorite light!