답안 #226094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226094 2020-04-22T14:06:30 Z farmerboy Snake (CEOI08_snake) C++14
35 / 100
1 ms 504 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, rightLow = 0, rightHigh = MAXN;
    char a1, a2;
    FOR(i,1,13) {
        rightLow = min(rightLow + k, MAXN-1);
        rightHigh = min(rightHigh + k, MAXN);
        int leftMid = (leftLow + leftHigh - 1) / 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);
            rightLow = max(rightLow, leftLow);
        }
        else if (a1 == 's') {
            leftHigh = leftMid + 1;
            rightLow = max(rightLow, leftMid);
        }
        else {
            leftHigh = leftMid;
            rightHigh = min(rightHigh, leftHigh);
        }

        if (a2 == 'b') {
            rightLow = min(rightMid + 1, MAXN-1);
            leftLow = max(leftLow, rightLow);
        }
        else if (a2 == 's') {
            rightLow = rightMid;
            leftHigh = min(leftHigh, rightMid + 1);
        }
        else {
            rightHigh = rightMid;
            leftHigh = min(leftHigh, rightHigh);
        }
    }
    int maxRes = rightHigh - leftLow + 1, minRes = rightLow - leftHigh + 1;
    // cout << leftLow << ' ' << leftHigh << ' ' << rightLow << ' ' << rightHigh << endl;
    int guess = (maxRes + minRes) / 2;
    tell_length(guess);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
2 Incorrect 1 ms 336 KB your estimate differs too much (7 units)
3 Incorrect 1 ms 504 KB your estimate differs too much (16 units)
4 Incorrect 1 ms 336 KB your estimate differs too much (24 units)
5 Incorrect 1 ms 336 KB your estimate differs too much (31 units)
6 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
7 Incorrect 1 ms 336 KB your estimate differs too much (2 units)
8 Incorrect 1 ms 336 KB your estimate differs too much (14 units)
9 Incorrect 1 ms 336 KB your estimate differs too much (26 units)
10 Incorrect 1 ms 336 KB your estimate differs too much (38 units)
11 Incorrect 1 ms 336 KB your estimate differs too much (50 units)
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 (62 units)
14 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
15 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
16 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
17 Incorrect 1 ms 336 KB your estimate differs too much (2 units)
18 Incorrect 1 ms 336 KB your estimate differs too much (4 units)
19 Correct 1 ms 336 KB Output is correct: estimate ok. 13 calls needed
20 Incorrect 1 ms 336 KB your estimate differs too much (5 units)