답안 #226085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226085 2020-04-22T13:44:11 Z farmerboy Snake (CEOI08_snake) C++14
5 / 100
5 ms 384 KB
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#include "snakelib.h"
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 12122;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int k = get_speed();
    int leftLow = 0, leftHigh = MAXN-1, rightLow = 0, rightHigh = MAXN-1;
    char a1, a2;
    FOR(i,1,13) {
        rightLow = min(rightLow + k, MAXN-1);
        rightHigh = min(rightHigh + k, MAXN-1);
        int leftMid = (leftLow + leftHigh) / 2;
        int rightMid = (rightLow + rightHigh) / 2;
        if (i == 1) {
            leftMid = (leftLow + leftLow + leftHigh) / 3;
            rightMid = (rightLow + rightHigh + rightHigh) / 3;
        }
        ask_snake(leftMid, rightMid, &a1, &a2);

        if (a1 == 'b') {
            leftLow = min(leftMid + 1, MAXN-1);
            leftHigh = max(leftHigh, leftLow);
        }
        else if (a1 == 's') {
            leftHigh = leftMid;
            rightLow = max(rightLow, leftMid);
        }
        else {
            leftHigh = max(0, leftMid - 1);
            rightHigh = min(rightHigh, leftHigh);
        }

        if (a2 == 'b') {
            rightLow = min(rightMid + 1, MAXN-1);
            leftLow = max(leftLow, rightLow);
        }
        else if (a2 == 's') {
            rightHigh = rightMid;
            leftHigh = min(leftHigh, rightMid);
        }
        else {
            rightHigh = max(0, rightMid - 1);
            leftHigh = min(leftHigh, rightHigh);
        }
    }
    int maxRes = rightHigh - leftLow + 1, minRes = rightLow - leftHigh + 1;
    int guess = (maxRes + minRes) / 2;
    tell_length(guess);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB your estimate differs too much (8080 units)
2 Incorrect 5 ms 384 KB your estimate differs too much (5688 units)
3 Incorrect 5 ms 384 KB your estimate differs too much (520 units)
4 Incorrect 4 ms 384 KB your estimate differs too much (939 units)
5 Incorrect 5 ms 384 KB your estimate differs too much (234 units)
6 Incorrect 5 ms 384 KB your estimate differs too much (2 units)
7 Incorrect 5 ms 384 KB your estimate differs too much (2 units)
8 Incorrect 5 ms 384 KB your estimate differs too much (14 units)
9 Incorrect 4 ms 384 KB your estimate differs too much (26 units)
10 Incorrect 5 ms 384 KB your estimate differs too much (38 units)
11 Incorrect 5 ms 384 KB your estimate differs too much (50 units)
12 Correct 5 ms 384 KB Output is correct: estimate ok. 13 calls needed
13 Incorrect 5 ms 384 KB your estimate differs too much (62 units)
14 Incorrect 5 ms 384 KB your estimate differs too much (2021 units)
15 Incorrect 4 ms 384 KB your estimate differs too much (4017 units)
16 Incorrect 5 ms 384 KB your estimate differs too much (7647 units)
17 Incorrect 5 ms 384 KB your estimate differs too much (1583 units)
18 Incorrect 4 ms 384 KB your estimate differs too much (4368 units)
19 Incorrect 5 ms 308 KB your estimate differs too much (1453 units)
20 Incorrect 5 ms 384 KB your estimate differs too much (248 units)