結果

問題 No.2658 L-R Nim
ユーザー てんぷらてんぷら
提出日時 2024-02-29 01:27:54
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,069 bytes
コンパイル時間 5,259 ms
コンパイル使用メモリ 314,788 KB
実行使用メモリ 463,888 KB
最終ジャッジ日時 2024-02-29 02:35:01
合計ジャッジ時間 44,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,644 KB
testcase_01 AC 7 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 212 ms
83,904 KB
testcase_06 AC 7 ms
11,584 KB
testcase_07 AC 208 ms
83,904 KB
testcase_08 AC 219 ms
83,904 KB
testcase_09 AC 211 ms
83,904 KB
testcase_10 AC 7 ms
11,584 KB
testcase_11 AC 212 ms
83,904 KB
testcase_12 AC 19 ms
11,584 KB
testcase_13 AC 7 ms
11,584 KB
testcase_14 AC 6 ms
11,584 KB
testcase_15 AC 213 ms
83,904 KB
testcase_16 AC 7 ms
11,584 KB
testcase_17 AC 208 ms
83,904 KB
testcase_18 AC 210 ms
83,904 KB
testcase_19 AC 7 ms
11,584 KB
testcase_20 AC 214 ms
83,904 KB
testcase_21 AC 7 ms
11,584 KB
testcase_22 AC 9 ms
11,584 KB
testcase_23 AC 207 ms
83,904 KB
testcase_24 AC 210 ms
83,904 KB
testcase_25 AC 2,958 ms
463,888 KB
testcase_26 AC 2,932 ms
463,888 KB
testcase_27 AC 2,942 ms
463,888 KB
testcase_28 AC 2,895 ms
463,888 KB
testcase_29 AC 2,989 ms
463,888 KB
testcase_30 AC 2,993 ms
463,888 KB
testcase_31 AC 2,928 ms
463,888 KB
testcase_32 AC 2,990 ms
463,888 KB
testcase_33 AC 12 ms
11,756 KB
testcase_34 AC 2,384 ms
463,888 KB
testcase_35 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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], ri = r[s[i] ^ v];
                if(li != -1 && li < i) {
                    ng[li][j][k]++;
                    ng[i][j][k]--;
                }
                if(ri != -1 && i < ri) {
                    ng[i][j][k]++;
                    ng[ri][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