結果

問題 No.2658 L-R Nim
ユーザー SnowBeenDidingSnowBeenDiding
提出日時 2024-03-01 22:55:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,433 bytes
コンパイル時間 5,385 ms
コンパイル使用メモリ 314,528 KB
実行使用メモリ 8,456 KB
最終ジャッジ日時 2024-03-01 22:57:30
合計ジャッジ時間 110,511 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 WA -
testcase_06 AC 6 ms
6,548 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 6 ms
6,548 KB
testcase_10 AC 6 ms
6,548 KB
testcase_11 WA -
testcase_12 AC 6 ms
6,548 KB
testcase_13 AC 6 ms
6,548 KB
testcase_14 AC 6 ms
6,548 KB
testcase_15 WA -
testcase_16 AC 6 ms
6,548 KB
testcase_17 AC 7 ms
6,548 KB
testcase_18 AC 551 ms
6,548 KB
testcase_19 AC 6 ms
6,548 KB
testcase_20 WA -
testcase_21 AC 6 ms
6,548 KB
testcase_22 AC 6 ms
6,548 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 18 ms
6,548 KB
testcase_34 AC 25 ms
6,548 KB
testcase_35 AC 1,784 ms
6,548 KB
testcase_36 AC 30 ms
6,548 KB
testcase_37 AC 20 ms
6,548 KB
testcase_38 AC 4,576 ms
8,456 KB
testcase_39 AC 4,602 ms
8,456 KB
testcase_40 AC 4,622 ms
8,456 KB
testcase_41 AC 4,636 ms
8,456 KB
testcase_42 AC 4,568 ms
8,456 KB
testcase_43 AC 4,565 ms
8,456 KB
testcase_44 AC 4,635 ms
8,456 KB
testcase_45 AC 4,597 ms
8,456 KB
testcase_46 AC 4,579 ms
8,456 KB
testcase_47 AC 4,576 ms
8,456 KB
testcase_48 WA -
testcase_49 AC 4,578 ms
8,456 KB
testcase_50 AC 4,602 ms
8,456 KB
testcase_51 AC 4,580 ms
8,456 KB
testcase_52 AC 4,583 ms
8,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace std;
using namespace atcoder;

typedef long long ll;

int f(vector<int> a) {
    int n = a.size();
    unordered_map<int, int> ma;
    int x = 0;
    ma[0]++;
    rep(i, 0, n) {
        x ^= a[i];
        ma[x]++;
    }
    x = 0;
    int ct = 0;
    rep(i, 0, n) {
        ma[x]--;
        ct += ma[x];
        x ^= a[i];
    }
    return ct;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    unordered_map<int, int> ma;
    int x = 0;
    ma[0]++;
    rep(i, 0, n) {
        x ^= a[i];
        ma[x]++;
    }
    x = 0;
    int l = 0;
    int ct = 0;
    rep(i, 0, n) {
        ma[x]--;
        ct += ma[x];
        if (ma[x]) l = i;
        x ^= a[i];
    }
    if (ct >= 2) {
        cout << "No" << endl;
        return 0;
    }
    if (ct == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    int r = l;
    x = a[l];
    while (x != 0) {
        r++;
        x ^= a[r];
    }
    rep(i, -k, +k + 1) {
        a[l] += i;
        int ct = f(a);
        if (ct == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a[l] -= i;
        a[r] += i;
        ct = f(a);
        if (ct == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a[r] -= i;
    }
    cout << "No" << endl;
}
0