結果

問題 No.2658 L-R Nim
ユーザー SnowBeenDidingSnowBeenDiding
提出日時 2024-03-01 22:54:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,413 bytes
コンパイル時間 5,371 ms
コンパイル使用メモリ 316,268 KB
実行使用メモリ 15,280 KB
最終ジャッジ日時 2024-03-01 22:54:34
合計ジャッジ時間 15,930 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 9 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 8 ms
6,676 KB
testcase_10 AC 8 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 9 ms
6,676 KB
testcase_13 AC 8 ms
6,676 KB
testcase_14 AC 9 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 9 ms
6,676 KB
testcase_17 AC 9 ms
6,676 KB
testcase_18 AC 1,310 ms
6,676 KB
testcase_19 AC 9 ms
6,676 KB
testcase_20 WA -
testcase_21 AC 9 ms
6,676 KB
testcase_22 AC 9 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
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>

#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();
    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];
    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