結果

問題 No.973 余興
ユーザー shibh308shibh308
提出日時 2019-12-06 09:57:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,214 bytes
コンパイル時間 2,940 ms
コンパイル使用メモリ 218,648 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-05-10 02:02:45
合計ジャッジ時間 18,244 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 208 ms
6,528 KB
testcase_01 AC 220 ms
6,528 KB
testcase_02 AC 215 ms
6,528 KB
testcase_03 AC 214 ms
6,784 KB
testcase_04 AC 212 ms
6,528 KB
testcase_05 AC 210 ms
6,656 KB
testcase_06 AC 216 ms
6,656 KB
testcase_07 AC 222 ms
6,656 KB
testcase_08 AC 206 ms
6,528 KB
testcase_09 AC 214 ms
6,656 KB
testcase_10 AC 205 ms
6,528 KB
testcase_11 AC 1,650 ms
5,376 KB
testcase_12 AC 1,660 ms
5,376 KB
testcase_13 AC 1,639 ms
5,376 KB
testcase_14 AC 1,628 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 9 ms
5,376 KB
testcase_19 AC 9 ms
5,376 KB
testcase_20 AC 8 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 10 ms
5,376 KB
testcase_24 AC 9 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 8 ms
5,376 KB
testcase_27 AC 13 ms
5,376 KB
testcase_28 AC 9 ms
5,376 KB
testcase_29 AC 9 ms
5,376 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

#define body(x) ((x) >> 6)
#define head(x) ((x) & 63)

signed main(){
    int n, x;
    cin >> n >> x;
    vector<int> v(n);
    int i, j, k, left, right;
    for(auto& w : v)
        cin >> w;

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

    array<int, 5000> nex, prev;
    for(i = 0; i < n; ++i){
        auto it = upper_bound(r.begin(), r.end(), r[i] + x);
        int idx = distance(r.begin(), it);
        nex[i] = min(idx, n);
        auto it2 = lower_bound(r.begin(), r.end(), r[i + 1] - x);
        idx = distance(r.begin(), it2);
        prev[i] = max(0, idx - 1);
    }

    array<int64_t, 390625> a;

    for(k = 1; k < n; ++k)
        for(i = 0, j = k; j < n; ++i, ++j){
            bool f = false;
            for(right = max(i, prev[j]); right < j; ++right){
                if(!((i * 5000 + right) & 63) && i * 5000 + right + 64 < j){
                    if(__builtin_popcountll(a[body(i * 5000 + right)]) != 64){
                        f = true;
                        break;
                    }
                    right += 63;
                }
                else if(!(a[body(i * 5000 + right)] & (1LL << head(i * 5000 + right)))){
                    f = true;
                    break;
                }
            }
            int left_bound = min(nex[i], j + 1);
            if(!f)
                for(left = i + 1; left < left_bound; ++left){
                    if(!((left * 5000 + j) & 63) && left * 5000 + j + 64 < j){
                        if(__builtin_popcountll(a[body(left * 5000 + j)]) != 64){
                            f = true;
                            break;
                        }
                        left += 63;
                    }
                    else if(!(a[body(left * 5000 + j)] & (1LL << head(left * 5000 + j)))){
                        f = true;
                        break;
                    }
                }

            a[body(i * 5000 + j)] |= i64(f) << head(i * 5000 + j);
        }

    cout << (a[body(n - 1)] & (1L << head(n - 1)) ? "A" : "B") << endl;
}

0