結果

問題 No.2658 L-R Nim
ユーザー sotanishysotanishy
提出日時 2024-03-02 00:02:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,328 bytes
コンパイル時間 3,360 ms
コンパイル使用メモリ 261,288 KB
実行使用メモリ 15,252 KB
最終ジャッジ日時 2024-03-02 00:03:17
合計ジャッジ時間 27,898 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 33 ms
6,676 KB
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 52 ms
6,676 KB
testcase_08 AC 58 ms
6,676 KB
testcase_09 AC 3,433 ms
6,676 KB
testcase_10 AC 6 ms
6,676 KB
testcase_11 AC 3,532 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 5 ms
6,676 KB
testcase_15 AC 53 ms
6,676 KB
testcase_16 AC 5 ms
6,676 KB
testcase_17 AC 2,734 ms
6,676 KB
testcase_18 AC 2,135 ms
6,676 KB
testcase_19 AC 5 ms
6,676 KB
testcase_20 AC 950 ms
6,676 KB
testcase_21 AC 5 ms
6,676 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 34 ms
6,676 KB
testcase_24 AC 1,774 ms
6,676 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrep(i, t, s) for (int i = (int)(t)-1; i >= (int)(s); --i)
#define all(x) begin(x), end(x)
template <typename T>
bool chmax(T& a, const T& b) {
    return a < b ? (a = b, 1) : 0;
}
template <typename T>
bool chmin(T& a, const T& b) {
    return a > b ? (a = b, 1) : 0;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i < (int)v.size() - 1) os << " ";
    }
    return os;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto& x : A) cin >> x;
    vector<int> B(N + 1);
    rep(i, 0, N) B[i + 1] = B[i] ^ A[i];
    map<int, int> prv;
    int left = 0;
    int right = N;
    bool f = false;
    rep(i, 0, N + 1) {
        if (prv.contains(B[i])) {
            if (prv[B[i]] == -1) {
                cout << "No" << endl;
                return 0;
            }
            chmax(left, prv[B[i]]);
            chmin(right, i);
            prv[B[i]] = -1;
            f = true;
        } else {
            prv[B[i]] = i;
        }
    }
    if (left >= right) {
        cout << "No" << endl;
        return 0;
    }
    if (!f) {
        cout << "Yes" << endl;
    }

    set<int> cand;
    rep(i, left, right) {
        rep(x, max(1, A[i] - K), A[i] + K + 1) cand.insert(x ^ A[i]);
    }
    for (int x : cand) {
        map<int, int> first;
        vector<int> banned(N + 1);
        rep(i, 0, N + 1) {
            if (first.contains(B[i] ^ x)) {
                int l = first[B[i] ^ x];
                ++banned[l];
                --banned[i];
            }
            if (!first.contains(B[i])) {
                first[B[i]] = i;
            }
        }
        rep(i, 0, N) banned[i + 1] += banned[i];
        rep(i, left, right) {
            if (!banned[i]) {
                rep(y, max(1, A[i] - K), A[i] + K + 1) {
                    if ((A[i] ^ x) == y) {
                        cout << "Yes" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "No" << endl;
}
0