Submission #201716

#TimeUsernameProblemLanguageResultExecution timeMemory
201716stefdascaSnake (CEOI08_snake)C++14
0 / 100
6 ms376 KiB
#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 timeMemoryGrader output
Fetching results...