# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
719374 | rainboy | Snake (CEOI08_snake) | C++17 | 1 ms | 560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include "snakelib.h"
#define N 12122
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
int k, llower, lupper, rlower, rupper, l, r;
char c1, c2;
k = get_speed();
llower = 0, lupper = N - 1, rlower = 0, rupper = N - 1;
l = (N - 1) / 3, r = (N - 1) * 2 / 3;
ask_snake(l, r, &c1, &c2);
if (c1 == 'b')
llower = max(llower, l + 1), rlower = max(rlower, l + 1);
else if (c1 == 'f')
lupper = min(lupper, l - 1), rupper = min(rupper, l - 1);
else
lupper = min(lupper, l), rlower = max(rlower, l);
if (c2 == 'b')
llower = max(llower, r + 1), rlower = max(rlower, r + 1);
else if (c2 == 'f')
lupper = min(lupper, r - 1), rupper = min(rupper, r - 1);
else
lupper = min(lupper, r), rlower = max(rlower, r);
while ((rupper - llower + 1) - max(rlower - lupper + 1, 1) > k * 2) {
lupper = min(lupper + k, N);
rupper = min(rupper + k, N);
l = (llower + lupper) / 2, r = min((rlower + rupper) / 2 + 1, N - 1);
ask_snake(l, r, &c1, &c2);
if (c1 == 'b')
llower = l + 1;
else
lupper = l;
if (c2 == 'f')
rupper = r - 1;
else
rlower = r;
}
tell_length(max(rlower - lupper + 1, 1) + k);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |