結果

問題 No.2658 L-R Nim
ユーザー てんぷらてんぷら
提出日時 2024-02-29 01:33:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5,231 ms / 7,000 ms
コード長 1,937 bytes
コンパイル時間 7,015 ms
コンパイル使用メモリ 316,032 KB
実行使用メモリ 472,112 KB
最終ジャッジ日時 2024-02-29 02:35:29
合計ジャッジ時間 58,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
19,756 KB
testcase_01 AC 6 ms
11,516 KB
testcase_02 AC 10 ms
19,780 KB
testcase_03 AC 6 ms
11,516 KB
testcase_04 AC 6 ms
11,516 KB
testcase_05 AC 188 ms
92,176 KB
testcase_06 AC 7 ms
11,584 KB
testcase_07 AC 182 ms
92,176 KB
testcase_08 AC 188 ms
92,176 KB
testcase_09 AC 182 ms
92,176 KB
testcase_10 AC 7 ms
11,584 KB
testcase_11 AC 187 ms
92,176 KB
testcase_12 AC 7 ms
11,584 KB
testcase_13 AC 7 ms
11,584 KB
testcase_14 AC 7 ms
11,584 KB
testcase_15 AC 186 ms
92,176 KB
testcase_16 AC 7 ms
11,584 KB
testcase_17 AC 183 ms
92,176 KB
testcase_18 AC 184 ms
92,176 KB
testcase_19 AC 6 ms
11,584 KB
testcase_20 AC 182 ms
92,176 KB
testcase_21 AC 7 ms
11,584 KB
testcase_22 AC 7 ms
11,584 KB
testcase_23 AC 184 ms
92,176 KB
testcase_24 AC 182 ms
92,176 KB
testcase_25 AC 1,745 ms
472,112 KB
testcase_26 AC 1,726 ms
472,112 KB
testcase_27 AC 1,695 ms
472,112 KB
testcase_28 AC 1,708 ms
472,112 KB
testcase_29 AC 1,758 ms
472,112 KB
testcase_30 AC 1,712 ms
472,112 KB
testcase_31 AC 1,704 ms
472,112 KB
testcase_32 AC 1,710 ms
472,112 KB
testcase_33 AC 9 ms
11,756 KB
testcase_34 AC 1,473 ms
472,112 KB
testcase_35 AC 5,231 ms
309,224 KB
testcase_36 AC 1,670 ms
472,112 KB
testcase_37 AC 10 ms
11,840 KB
testcase_38 AC 1,708 ms
472,112 KB
testcase_39 AC 1,704 ms
472,112 KB
testcase_40 AC 1,755 ms
472,112 KB
testcase_41 AC 1,761 ms
472,112 KB
testcase_42 AC 1,725 ms
472,112 KB
testcase_43 AC 1,731 ms
472,112 KB
testcase_44 AC 1,696 ms
472,112 KB
testcase_45 AC 1,703 ms
472,112 KB
testcase_46 AC 1,703 ms
472,112 KB
testcase_47 AC 1,756 ms
472,112 KB
testcase_48 AC 1,619 ms
472,112 KB
testcase_49 AC 1,686 ms
472,112 KB
testcase_50 AC 1,742 ms
472,112 KB
testcase_51 AC 1,720 ms
472,112 KB
testcase_52 AC 1,715 ms
472,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;
const int inf = 1000000007;
const ll longinf = 1ll << 60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> s(n + 1);
    rep(i, n) s[i + 1] = s[i] ^ a[i];
    int m = 1 << 20;
    vector<int> l(m, -1), r(m, -1);
    int left = -1, right = n + 1;
    rep(i, n + 1) {
        if(r[s[i]] != -1) {
            left = max(left, r[s[i]]);
            right = min(right, i);
        }
        r[s[i]] = i;
        if(l[s[i]] == -1) {
            l[s[i]] = i;
        }
    }
    if(left >= right) {
        cout << "No" << endl;
        return 0;
    }
    if(left == -1) {
        cout << "Yes" << endl;
        return 0;
    }
    vector ng(n + 1, vector(128, vector(14, short(0))));
    rep(i, n + 1) {
        rep(j, 128) {
            rep(k, 14) {
                int v = j | ((1 << k) - 1) << 7;
                int li = l[s[i] ^ v];
                if(li != -1 && li < i) {
                    ng[li][j][k]++;
                    ng[i][j][k]--;
                }
            }
        }
    }
    rep(i, n) rep(j, 128) rep(k, 14) ng[i + 1][j][k] += ng[i][j][k];
    bool can = false;
    vector<pair<int, int>> p(1 << 20);
    rep(j, 128) rep(k, 14) {
        int v = j | ((1 << k) - 1) << 7;
        p[v] = {j, k};
    }
    REP(i, left, right) {
        for(int j = max(1, a[i] - k); j <= a[i] + k; j++) {
            auto [v, c] = p[j ^ a[i]];
            if(!ng[i][v][c]) {
                can = true;
                break;
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}
0