結果

問題 No.973 余興
ユーザー shibh308shibh308
提出日時 2019-12-05 22:13:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,200 bytes
コンパイル時間 3,209 ms
コンパイル使用メモリ 222,576 KB
実行使用メモリ 199,296 KB
最終ジャッジ日時 2024-05-10 01:45:11
合計ジャッジ時間 67,282 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1,663 ms
199,168 KB
testcase_02 AC 1,659 ms
199,168 KB
testcase_03 WA -
testcase_04 AC 1,785 ms
199,040 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,623 ms
191,360 KB
testcase_11 AC 645 ms
73,856 KB
testcase_12 AC 627 ms
73,984 KB
testcase_13 WA -
testcase_14 AC 607 ms
73,216 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 26 ms
8,320 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 42 ms
11,392 KB
testcase_23 AC 34 ms
9,856 KB
testcase_24 AC 34 ms
9,728 KB
testcase_25 AC 16 ms
6,940 KB
testcase_26 AC 26 ms
8,320 KB
testcase_27 AC 53 ms
12,416 KB
testcase_28 WA -
testcase_29 AC 34 ms
9,728 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2,037 ms
198,144 KB
testcase_35 AC 1,948 ms
199,040 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,936 ms
198,400 KB
testcase_39 WA -
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 2 ms
6,940 KB
testcase_44 AC 2 ms
6,940 KB
testcase_45 WA -
testcase_46 AC 1,924 ms
199,040 KB
testcase_47 WA -
testcase_48 AC 1,913 ms
199,040 KB
testcase_49 WA -
testcase_50 AC 1,915 ms
197,504 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 2,017 ms
195,584 KB
testcase_54 AC 1,985 ms
199,168 KB
testcase_55 AC 1,973 ms
199,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

template <typename T>
struct BIT{
    vector<T> elm;
    BIT(int n, T init = T()) : elm(n + 1, init){
    }

    // [0, x)
    T sum(int x){
        T val = 0;
        for(; x > 0; x -= x & -x)
            val += elm[x];
        return val;
    }

    // [l, r)
    T sum(int l, int r){
        return sum(r) - sum(l);
    }

    void add(int x, T val){
        for(++x; x < elm.size(); x += x & -x)
            elm[x] += val;
    }
};

signed main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    for(auto& x : v)
        cin >> x;

    vector<i64> r(n + 1, 0);
    for(int i = 0; i < n; ++i)
        r[i + 1] = r[i] + v[i];

    vector<int> nex(n, n), prev(n, 0);
    for(int i = 0; i < n; ++i){
        auto it = upper_bound(r.begin(), r.end(), r[i] + x);
        int idx = distance(r.begin(), it);
        nex[i] = idx - 1;
        auto it2 = lower_bound(r.begin(), r.end(), r[i + 1] - x);
        idx = distance(r.begin(), it2);
        prev[i] = idx + 1;
    }
    /*
    for(auto& x : nex)
        cout << x << " ";
    cout << endl;
    for(auto& x : prev)
        cout << x << " ";
    cout << endl;
     */

    vector<BIT<int>> a(n, BIT<int>(n)), b(n, BIT<int>(n));

    for(int k = 1; k < n; ++k)
        for(int i = 0, j = k; j < n; ++i, ++j){
            bool f = false;
            // TODO: set len

            // dp[i][j] : dp[i][j - x, j)
            // cout << j - prev[j] << "   " << nex[i] - (i + 1) << "    ";
            f |= (a[i].sum(max(i, prev[j]), j) != (j - max(i, prev[j])));

            // dp[i][j] : dp[i, i + x][j, j)
            f |= (b[j].sum(i + 1, min(nex[i], j + 1)) != (min(nex[i], j + 1) - (i + 1)));
            if(f){
                a[i].add(j, 1);
                b[j].add(i, 1);
            }
            // cout << "[" << i << "," << j << "] -> " << (f ? "Win" : "Lose") << endl;
        }

    /*
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j)
            cout << a[i].sum(j, j + 1) << " \n"[j == n - 1];
    }
    cout << endl;
     */
    cout << (a[0].sum(n - 1, n) ? "A" : "B") << endl;
}
0