結果
問題 |
No.2658 L-R Nim
|
ユーザー |
![]() |
提出日時 | 2024-03-01 23:15:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,004 bytes |
コンパイル時間 | 2,949 ms |
コンパイル使用メモリ | 278,156 KB |
実行使用メモリ | 51,152 KB |
最終ジャッジ日時 | 2024-09-29 15:08:23 |
合計ジャッジ時間 | 55,481 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 47 WA * 1 |
ソースコード
#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"; }