# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
680506 |
2023-01-11T02:29:40 Z |
jhwest2 |
Colors (BOI20_colors) |
C++17 |
|
0 ms |
208 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
bool debug = 1;
int last = 0, C = 1;
bool ask(ll x) {
assert(1 <= x && x <= n);
bool res;
cout << "? " << x << endl;
if (debug) {
if (abs(last - x) >= C)
res = 1;
else
res = 0;
last = x;
cout << res << endl;
}
else
cin >> res;
return res;
}
int main() {
cin >> n;
// finding the starting position
ll L = 1, R = n, x = 0, dir = 0;
ll minv = 0, maxv = 0;
while (L < R) {
ll M = (L + R) / 2;
if (dir == 0) {
x += M;
maxv = max(maxv, x);
}
else {
x -= M;
minv = min(minv, x);
}
dir = 1 - dir;
L = M + 1;
}
assert(maxv - minv <= n - 1);
L = 1; R = n; x = 1 - minv; dir = 0;
ask(x);
while (L < R) {
ll M = (L + R) / 2;
bool r;
if (dir == 0) {
r = ask(x + M);
x += M;
}
else {
r = ask(x - M);
x -= M;
}
dir = 1 - dir;
if (r)
R = M;
else
L = M + 1;
}
cout << "= " << L << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]" |
2 |
Halted |
0 ms |
0 KB |
- |