Submission #441556

# Submission time Handle Problem Language Result Execution time Memory
441556 2021-07-05T11:09:24 Z jeroenodb Snake (CEOI08_snake) C++14
0 / 100
1 ms 200 KB
/*
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 time Memory Grader output
1 Runtime error 1 ms 200 KB Execution killed with signal 13
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Runtime error 1 ms 200 KB Execution killed with signal 13
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Runtime error 1 ms 200 KB Execution killed with signal 13
6 Runtime error 1 ms 200 KB Execution killed with signal 13
7 Runtime error 0 ms 200 KB Execution killed with signal 13
8 Runtime error 1 ms 200 KB Execution killed with signal 13
9 Runtime error 1 ms 200 KB Execution killed with signal 13
10 Runtime error 0 ms 200 KB Execution killed with signal 13
11 Runtime error 1 ms 200 KB Execution killed with signal 13
12 Runtime error 1 ms 200 KB Execution killed with signal 13
13 Runtime error 0 ms 200 KB Execution killed with signal 13
14 Runtime error 1 ms 200 KB Execution killed with signal 13
15 Runtime error 1 ms 200 KB Execution killed with signal 13
16 Runtime error 1 ms 200 KB Execution killed with signal 13
17 Runtime error 1 ms 200 KB Execution killed with signal 13
18 Runtime error 1 ms 200 KB Execution killed with signal 13
19 Runtime error 1 ms 200 KB Execution killed with signal 13
20 Runtime error 1 ms 200 KB Execution killed with signal 13