Submission #226084

# Submission time Handle Problem Language Result Execution time Memory
226084 2020-04-22T13:43:10 Z farmerboy Snake (CEOI08_snake) C++14
0 / 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 = (rightMid + 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;
}

Compilation message

snake.cpp: In function 'int main()':
snake.cpp:46:34: warning: 'rightMid' is used uninitialized in this function [-Wuninitialized]
         int rightMid = (rightMid + rightHigh) / 2;
                        ~~~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB your estimate differs too much (10100 units)
2 Incorrect 4 ms 384 KB your estimate differs too much (5049 units)
3 Incorrect 5 ms 384 KB your estimate differs too much (1597 units)
4 Incorrect 5 ms 384 KB your estimate differs too much (186 units)
5 Incorrect 5 ms 384 KB your estimate differs too much (2834 units)
6 Incorrect 5 ms 384 KB your estimate differs too much (2019 units)
7 Incorrect 5 ms 384 KB your estimate differs too much (1012 units)
8 Incorrect 5 ms 384 KB your estimate differs too much (1006 units)
9 Incorrect 4 ms 384 KB your estimate differs too much (1001 units)
10 Incorrect 5 ms 384 KB your estimate differs too much (994 units)
11 Incorrect 5 ms 384 KB your estimate differs too much (989 units)
12 Incorrect 5 ms 384 KB your estimate differs too much (2019 units)
13 Incorrect 5 ms 384 KB your estimate differs too much (982 units)
14 Incorrect 4 ms 384 KB your estimate differs too much (2023 units)
15 Incorrect 5 ms 384 KB your estimate differs too much (5033 units)
16 Incorrect 5 ms 384 KB your estimate differs too much (8657 units)
17 Incorrect 4 ms 384 KB your estimate differs too much (2454 units)
18 Incorrect 4 ms 384 KB your estimate differs too much (6901 units)
19 Incorrect 5 ms 384 KB your estimate differs too much (3107 units)
20 Incorrect 4 ms 384 KB your estimate differs too much (2809 units)