結果

問題 No.973 余興
ユーザー kcvlexkcvlex
提出日時 2020-01-18 00:05:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,404 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 166,456 KB
実行使用メモリ 110,988 KB
最終ジャッジ日時 2023-09-08 09:08:16
合計ジャッジ時間 4,765 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 32 ms
110,500 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 32 ms
104,524 KB
testcase_06 AC 33 ms
107,328 KB
testcase_07 AC 33 ms
106,704 KB
testcase_08 AC 33 ms
110,988 KB
testcase_09 AC 34 ms
106,948 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 22 ms
65,096 KB
testcase_14 WA -
testcase_15 AC 9 ms
30,008 KB
testcase_16 AC 9 ms
30,060 KB
testcase_17 WA -
testcase_18 AC 8 ms
27,756 KB
testcase_19 AC 8 ms
27,824 KB
testcase_20 AC 8 ms
24,188 KB
testcase_21 AC 9 ms
30,152 KB
testcase_22 AC 9 ms
30,032 KB
testcase_23 AC 8 ms
27,776 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 8 ms
27,752 KB
testcase_29 WA -
testcase_30 AC 36 ms
89,608 KB
testcase_31 AC 35 ms
89,748 KB
testcase_32 AC 36 ms
89,608 KB
testcase_33 AC 37 ms
89,644 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 36 ms
90,120 KB
testcase_37 AC 36 ms
90,060 KB
testcase_38 WA -
testcase_39 AC 37 ms
90,248 KB
testcase_40 AC 2 ms
7,556 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 2 ms
7,444 KB
testcase_44 WA -
testcase_45 AC 3 ms
11,812 KB
testcase_46 WA -
testcase_47 AC 40 ms
82,296 KB
testcase_48 WA -
testcase_49 AC 37 ms
82,264 KB
testcase_50 WA -
testcase_51 AC 40 ms
81,460 KB
testcase_52 AC 35 ms
94,880 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const size_t SIZE = 5010;
int bit_l[SIZE][SIZE];
int bit_r[SIZE][SIZE];
bool calced[SIZE][SIZE][2];
int cnt_r[SIZE], cnt_l[SIZE];
int A[SIZE];
int N, X;

int get_sum(int pos, int bit_v[]) {
    int ret = 0;
    for(; 0 < pos; pos -= pos & -pos) ret += bit_v[pos];
    return ret;
}

int get_sum(int l, int r, int bit_v[]) { 
    if (r <= l) return 0;
    return get_sum(r, bit_v) - get_sum(l, bit_v); 
}

void add(int pos, int delta, int bit_v[]) {
    for(++pos; pos < SIZE; pos += pos & -pos) bit_v[pos] += delta;
}

void shaku(int max_v[]) {
    int l = 0, r = 0;
    int sum = 0;
    for (int l = 0; l < N; l++) {
        while (r < N && sum + A[r] <= X) {
            sum += A[r];
            r++;
        }
        max_v[l] = r - l;
        sum -= A[l];
    }
}

bool calc0(int i, int j);
bool calc1(int i, int j);

bool calc0(int i, int j) {
    if (i == j) return false;
    if (!calced[i + 1][j][1]) calc1(i + 1, j);
    calced[i][j][0] = true;
    int cnt = get_sum(i + 1, i + cnt_r[i], bit_r[j]);
    bool win = cnt < cnt_r[i] - 1;
    add(j, win, bit_l[i]);
    add(i, !win, bit_r[j]);
    return win;
}

bool calc1(int i, int j) {
    if (i == j) return false;
    if (!calced[i][j - 1][0]) calc0(i, j - 1);
    calced[i][j][1] = true;
    int cnt = get_sum(j - cnt_l[j] + 1, j, bit_l[i]);
    bool win = cnt < cnt_l[j] - 1;
    add(i, win, bit_r[j]);
    add(j, !win, bit_l[i]);
    return win;
}

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) cin >> A[i];

    shaku(cnt_r);
    reverse(A, A + N);
    shaku(cnt_l);
    reverse(A, A + N);
    reverse(cnt_l, cnt_l + N);
    cout << (calc0(0, N - 1) ? "A" : "B") << endl;
    return 0;
}
0