답안 #441556

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441556 2021-07-05T11:09:24 Z jeroenodb Snake (CEOI08_snake) C++14
50 / 100
1 ms 600 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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct: estimate ok. 12 calls needed
2 Incorrect 1 ms 336 KB your estimate differs too much (7 units)
3 Correct 1 ms 336 KB Output is correct: estimate ok. 11 calls needed
4 Correct 1 ms 336 KB Output is correct: estimate ok. 10 calls needed
5 Incorrect 1 ms 336 KB your estimate differs too much (14 units)
6 Incorrect 1 ms 336 KB your estimate differs too much (1 units)
7 Incorrect 1 ms 336 KB your estimate differs too much (2 units)
8 Incorrect 1 ms 336 KB your estimate differs too much (5 units)
9 Incorrect 1 ms 336 KB your estimate differs too much (4 units)
10 Incorrect 1 ms 336 KB your estimate differs too much (5 units)
11 Correct 1 ms 336 KB Output is correct: estimate ok. 11 calls needed
12 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
13 Incorrect 1 ms 336 KB your estimate differs too much (7 units)
14 Correct 1 ms 336 KB Output is correct: estimate ok. 12 calls needed
15 Correct 1 ms 508 KB Output is correct: estimate ok. 12 calls needed
16 Correct 1 ms 504 KB Output is correct: estimate ok. 13 calls needed
17 Correct 1 ms 348 KB Output is correct: estimate ok. 12 calls needed
18 Incorrect 1 ms 600 KB your estimate differs too much (3 units)
19 Incorrect 1 ms 508 KB your estimate differs too much (6 units)
20 Correct 1 ms 500 KB Output is correct: estimate ok. 11 calls needed