제출 #201704

#제출 시각아이디문제언어결과실행 시간메모리
201704stefdascaSnake (CEOI08_snake)C++14
0 / 100
5 ms380 KiB
#include "snakelib.h" #include<bits/stdc++.h> using namespace std; int k; char x, y; void casework(int &st, int &dr, int mid1, int mid2) { if(x == 's' && y == 'f') dr = mid2 + k; if(x == 'b' && y == 'b') st = mid2; if(x == 'f' && y == 'f') dr = mid1 + k; if(x == 'f' && y == 'b') { st = mid1 - k; dr = mid2 + k; } if(x == 'f' && y == 's') st = mid1; } int main() { k = get_speed(); int st = 0; int dr = 12121; int qu = 13; while(qu) { int mid1 = st + (dr - st) / 3; int mid2 = dr - (dr - st) / 3; ask_snake(mid1, mid2, &x, &y); --qu; if(x == 's' && y == 's') { while(qu && x == 's' && y == 's') { mid1 = (st + mid1 - k) / 2; mid2 = (dr + mid2 + k) / 2; ask_snake(mid1, mid2, &x, &y); --qu; } casework(st, dr, mid1, mid2); } else casework(st, dr, mid1, mid2); } tell_length(dr - st + 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...