結果

問題 No.2658 L-R Nim
ユーザー てんぷらてんぷら
提出日時 2024-02-29 01:30:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5,471 ms / 7,000 ms
コード長 1,921 bytes
コンパイル時間 5,327 ms
コンパイル使用メモリ 314,656 KB
実行使用メモリ 463,888 KB
最終ジャッジ日時 2024-02-29 02:35:05
合計ジャッジ時間 61,176 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,644 KB
testcase_01 AC 6 ms
11,516 KB
testcase_02 AC 6 ms
11,644 KB
testcase_03 AC 6 ms
11,516 KB
testcase_04 AC 6 ms
11,516 KB
testcase_05 AC 160 ms
83,904 KB
testcase_06 AC 7 ms
11,584 KB
testcase_07 AC 163 ms
83,904 KB
testcase_08 AC 169 ms
83,904 KB
testcase_09 AC 160 ms
83,904 KB
testcase_10 AC 7 ms
11,584 KB
testcase_11 AC 161 ms
83,904 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 162 ms
83,904 KB
testcase_16 AC 7 ms
11,584 KB
testcase_17 AC 159 ms
83,904 KB
testcase_18 AC 157 ms
83,904 KB
testcase_19 AC 7 ms
11,584 KB
testcase_20 AC 161 ms
83,904 KB
testcase_21 AC 6 ms
11,584 KB
testcase_22 AC 7 ms
11,584 KB
testcase_23 AC 163 ms
83,904 KB
testcase_24 AC 161 ms
83,904 KB
testcase_25 AC 1,852 ms
463,888 KB
testcase_26 AC 1,894 ms
463,888 KB
testcase_27 AC 1,890 ms
463,888 KB
testcase_28 AC 1,796 ms
463,888 KB
testcase_29 AC 1,895 ms
463,888 KB
testcase_30 AC 1,894 ms
463,888 KB
testcase_31 AC 1,783 ms
463,888 KB
testcase_32 AC 1,862 ms
463,888 KB
testcase_33 AC 9 ms
11,756 KB
testcase_34 AC 1,533 ms
463,888 KB
testcase_35 AC 5,471 ms
301,052 KB
testcase_36 AC 1,613 ms
463,888 KB
testcase_37 AC 10 ms
11,840 KB
testcase_38 AC 1,699 ms
463,888 KB
testcase_39 AC 1,768 ms
463,888 KB
testcase_40 AC 1,788 ms
463,888 KB
testcase_41 AC 1,821 ms
463,888 KB
testcase_42 AC 1,786 ms
463,888 KB
testcase_43 AC 1,847 ms
463,888 KB
testcase_44 AC 1,759 ms
463,888 KB
testcase_45 AC 1,810 ms
463,888 KB
testcase_46 AC 1,839 ms
463,888 KB
testcase_47 AC 1,822 ms
463,888 KB
testcase_48 AC 1,787 ms
463,888 KB
testcase_49 AC 1,742 ms
463,888 KB
testcase_50 AC 1,853 ms
463,888 KB
testcase_51 AC 1,848 ms
463,888 KB
testcase_52 AC 1,800 ms
463,888 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;
    REP(i, left, right) {
        for(int j = max(1, a[i] - k); j <= a[i] + k; j++) {
            int v = j ^ a[i];
            int c = 0;
            while(v >> (7 + c) & 1) {
                v ^= 1 << (7 + c);
                ++c;
            }
            if(!ng[i][v][c]) {
                can = true;
                break;
            }
        }
    }
    cout << (can ? "Yes" : "No") << endl;
    return 0;
}
0