結果

問題 No.2658 L-R Nim
ユーザー SnowBeenDidingSnowBeenDiding
提出日時 2024-03-01 23:09:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,108 bytes
コンパイル時間 5,361 ms
コンパイル使用メモリ 315,188 KB
実行使用メモリ 10,400 KB
最終ジャッジ日時 2024-09-29 14:55:55
合計ジャッジ時間 32,121 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 1 TLE * 1 -- * 46
権限があれば一括ダウンロードができます

ソースコード

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];
    if (f(a) == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, 0, n) {
        a[i]++;
        if (f(a) == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a[i]--;
    }
    while (clock() < 6000000) {
        int ind = rand() % n;
        int ad = rand() % k + 1;
        if (rand() % 2) ad *= -1;
        a[ind] += ad;
        if (a[ind] > 0 && f(a) == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a[ind] -= ad;
    }
    cout << "No" << endl;
}
0