結果

問題 No.2658 L-R Nim
ユーザー KudeKude
提出日時 2024-03-01 23:15:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,004 bytes
コンパイル時間 3,873 ms
コンパイル使用メモリ 277,424 KB
実行使用メモリ 51,156 KB
最終ジャッジ日時 2024-03-01 23:17:06
合計ジャッジ時間 62,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 85 ms
17,844 KB
testcase_06 AC 299 ms
17,836 KB
testcase_07 AC 85 ms
17,844 KB
testcase_08 AC 86 ms
17,844 KB
testcase_09 AC 374 ms
17,832 KB
testcase_10 AC 287 ms
17,836 KB
testcase_11 AC 307 ms
17,828 KB
testcase_12 AC 321 ms
17,836 KB
testcase_13 AC 342 ms
17,832 KB
testcase_14 AC 309 ms
17,832 KB
testcase_15 AC 85 ms
17,840 KB
testcase_16 AC 316 ms
17,836 KB
testcase_17 AC 370 ms
17,832 KB
testcase_18 AC 330 ms
17,840 KB
testcase_19 AC 357 ms
17,852 KB
testcase_20 AC 134 ms
17,840 KB
testcase_21 AC 389 ms
17,852 KB
testcase_22 AC 330 ms
17,840 KB
testcase_23 AC 86 ms
17,836 KB
testcase_24 AC 188 ms
17,844 KB
testcase_25 AC 2,248 ms
51,144 KB
testcase_26 AC 658 ms
51,148 KB
testcase_27 AC 2,383 ms
51,144 KB
testcase_28 AC 2,267 ms
51,144 KB
testcase_29 AC 1,699 ms
51,148 KB
testcase_30 AC 964 ms
51,144 KB
testcase_31 AC 812 ms
51,140 KB
testcase_32 AC 2,226 ms
51,144 KB
testcase_33 AC 1,148 ms
35,292 KB
testcase_34 AC 2,296 ms
51,140 KB
testcase_35 AC 537 ms
28,948 KB
testcase_36 AC 2,267 ms
51,140 KB
testcase_37 WA -
testcase_38 AC 2,028 ms
51,144 KB
testcase_39 AC 2,205 ms
51,140 KB
testcase_40 AC 1,997 ms
51,140 KB
testcase_41 AC 2,232 ms
51,140 KB
testcase_42 AC 2,036 ms
51,140 KB
testcase_43 AC 2,106 ms
51,156 KB
testcase_44 AC 1,983 ms
51,140 KB
testcase_45 AC 2,108 ms
51,140 KB
testcase_46 AC 1,986 ms
51,140 KB
testcase_47 AC 2,056 ms
51,148 KB
testcase_48 AC 1,656 ms
51,140 KB
testcase_49 AC 1,777 ms
51,144 KB
testcase_50 AC 1,663 ms
51,140 KB
testcase_51 AC 2,284 ms
51,144 KB
testcase_52 AC 1,997 ms
51,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

int t1[1 << 20], t2[1 << 20];

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  VI a(n);
  rep(i, n) cin >> a[i];
  VI s(n + 1);
  rep(i, n) s[i+1] = s[i] ^ a[i];
  VI d; d.reserve(2 * (k + 1) * n);
  for (int x : a) {
    for (int y = x - k; y <= x + k; y++) if (y >= 0) {
      d.emplace_back(y ^ x);
    }
  }
  int left = 0, right = n;
  rep(i, n + 1) {
    if (t1[s[i]]) {
      right = i;
      break;
    }
    t1[s[i]]++;
  }
  for (int x : s) t1[x] = 0;
  rrep(i, n + 1) {
    if (t1[s[i]]) {
      left = i;
      break;
    }
    t1[s[i]]++;
  }
  for (int x : s) t2[x] = 0;
  sort(all(d));
  d.erase(unique(all(d)), d.end());
  // rep(i, n + 1) cout << s[i] << " \n"[i == n];

  for (int x : d) {
    t1[0]++;
    ll bad = 0;
    for (int i = 1; i <= n; i++) {
      t2[s[i]]++;
      bad += t1[s[i] ^ x];
    }
    // cout << "a2" << x << ' ' << bad << endl;
    rep(i, n) {
      // cout << i << endl;
      int diff = abs((x ^ a[i]) - a[i]);
      if (left <= i && i < right && diff <= k && bad == 0) {
        cout << "Yes\n";
        return 0;
      }
      bad -= t1[s[i+1] ^ x];
      t2[s[i+1]]--;
      t1[s[i+1]]++;
      bad += t2[s[i+1] ^ x];
    }
    rep(i, n + 1) t1[s[i]] = 0;
  }
  cout << "No\n";
}
0