Submission #441556

#TimeUsernameProblemLanguageResultExecution timeMemory
441556jeroenodbSnake (CEOI08_snake)C++14
50 / 100
1 ms600 KiB
/* ID: jeroen.3 TASK: snake LANG: C++ */ #include "snakelib.h" #include "bits/stdc++.h" using namespace std; #define all(x) x.begin(),x.end() template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #define debug(a) cerr << "(" << #a << ": " << a << ")\n"; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pi; const int L=12122, oo = 1e9; int l=0,r=L-1, a=0,b=L-1,k; void update() { r=min(r+k,L-1),b=min(b+k,L-1); } void handle(int i, char c) { if(c=='b') { l=max(l,i+1); a=max(a,i+2); } else if(c=='s') { r=min(r,i); a=max(a,i+1); } else if(c=='f') { r=min(r,i-1); b=min(b,i); } } void ask(int i, int j) { char q1,q2; ask_snake(i,j,&q1,&q2); handle(i,q1); handle(j,q2); } bool good() { return b-l - max(0,a-l) <=2*k; } int main() { // #ifndef LOCAL // freopen("snake.in", "r", stdin); // freopen("snake.out", "w", stdout); // #endif k=get_speed(); ask(L/3, 2*L/3); while(!good()) { update(); ask((l+r+1)/2, (a+b)/2); } tell_length((b-l+a-r)/2); }
#Verdict Execution timeMemoryGrader output
Fetching results...