# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201716 | stefdasca | Snake (CEOI08_snake) | C++14 | 6 ms | 376 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 "snakelib.h"
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a1, a2;
int k = get_speed();
int stL = -1;
int stR = 12122;
int drL = -1;
int drR = 12122;
int qu = 13;
for(; qu; --qu)
{
drL += k;
drR += k;
int midL = (stL + drL - 1) / 2;
int midR = (stR + drL) / 2;
if(stL == drL && stR == drR)
{
midL = stL + (stR - stL) / 3;
midR = stR + (drR - drL) * 2 / 3;
}
ask_snake(midL, midR, &a1, &a2);
if(a1 == 's')
{
stR = midL + 1;
drL = max(drL, midL);
}
else
if(a1 == 'f')
{
stR = midL;
drR = min(drR, midL);
}
else
if(a1 == 'b')
{
stL = midL + 1;
drL = max(drL, midL + 1);
}
if(a2 == 's')
{
drL = midR;
stR = min(stR, drL + 1);
}
else
if(a2 == 'f')
{
drR = midR;
stR = min(stR, drR);
}
else
if(a2 == 'f')
{
drL = midR + 1;
stR = max(stR, drL);
}
}
int max_ans = drR - stL + 1;
int min_ans = drL - stR + 1;
int guess = (max_ans + min_ans)/ 2;
tell_length(guess);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |