結果
問題 | No.2658 L-R Nim |
ユーザー | Misuki |
提出日時 | 2024-03-01 23:10:13 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3,249 ms / 7,000 ms |
コード長 | 3,336 bytes |
コンパイル時間 | 2,464 ms |
コンパイル使用メモリ | 209,712 KB |
実行使用メモリ | 11,884 KB |
最終ジャッジ日時 | 2024-09-29 15:04:21 |
合計ジャッジ時間 | 133,325 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,738 ms
11,632 KB |
testcase_01 | AC | 1,756 ms
11,556 KB |
testcase_02 | AC | 1,748 ms
11,516 KB |
testcase_03 | AC | 1,738 ms
11,652 KB |
testcase_04 | AC | 1,744 ms
11,600 KB |
testcase_05 | AC | 1,892 ms
11,568 KB |
testcase_06 | AC | 1,857 ms
11,664 KB |
testcase_07 | AC | 1,887 ms
11,616 KB |
testcase_08 | AC | 1,859 ms
11,584 KB |
testcase_09 | AC | 1,828 ms
11,588 KB |
testcase_10 | AC | 1,811 ms
11,652 KB |
testcase_11 | AC | 1,882 ms
11,728 KB |
testcase_12 | AC | 1,844 ms
11,756 KB |
testcase_13 | AC | 1,812 ms
11,736 KB |
testcase_14 | AC | 1,839 ms
11,640 KB |
testcase_15 | AC | 1,834 ms
11,604 KB |
testcase_16 | AC | 1,856 ms
11,732 KB |
testcase_17 | AC | 1,841 ms
11,636 KB |
testcase_18 | AC | 1,860 ms
11,652 KB |
testcase_19 | AC | 1,833 ms
11,692 KB |
testcase_20 | AC | 1,948 ms
11,576 KB |
testcase_21 | AC | 1,813 ms
11,616 KB |
testcase_22 | AC | 1,980 ms
11,740 KB |
testcase_23 | AC | 1,799 ms
11,692 KB |
testcase_24 | AC | 2,041 ms
11,612 KB |
testcase_25 | AC | 3,238 ms
11,836 KB |
testcase_26 | AC | 3,110 ms
11,792 KB |
testcase_27 | AC | 2,894 ms
11,820 KB |
testcase_28 | AC | 3,080 ms
11,776 KB |
testcase_29 | AC | 2,862 ms
11,868 KB |
testcase_30 | AC | 2,937 ms
11,848 KB |
testcase_31 | AC | 3,190 ms
11,784 KB |
testcase_32 | AC | 2,838 ms
11,780 KB |
testcase_33 | AC | 2,195 ms
11,884 KB |
testcase_34 | AC | 2,528 ms
11,772 KB |
testcase_35 | AC | 2,335 ms
11,832 KB |
testcase_36 | AC | 2,560 ms
11,716 KB |
testcase_37 | AC | 2,152 ms
11,756 KB |
testcase_38 | AC | 2,992 ms
11,824 KB |
testcase_39 | AC | 2,837 ms
11,776 KB |
testcase_40 | AC | 3,203 ms
11,872 KB |
testcase_41 | AC | 3,249 ms
11,640 KB |
testcase_42 | AC | 3,123 ms
11,828 KB |
testcase_43 | AC | 2,843 ms
11,672 KB |
testcase_44 | AC | 3,024 ms
11,876 KB |
testcase_45 | AC | 2,933 ms
11,720 KB |
testcase_46 | AC | 2,961 ms
11,792 KB |
testcase_47 | AC | 2,867 ms
11,756 KB |
testcase_48 | AC | 2,387 ms
11,716 KB |
testcase_49 | AC | 2,837 ms
11,652 KB |
testcase_50 | AC | 3,056 ms
11,832 KB |
testcase_51 | AC | 3,033 ms
11,696 KB |
testcase_52 | AC | 2,846 ms
11,688 KB |
ソースコード
#pragma GCC optimize("O2") #include <algorithm> #include <array> #include <bit> #include <bitset> #include <cassert> #include <cctype> #include <cfenv> #include <cfloat> #include <chrono> #include <cinttypes> #include <climits> #include <cmath> #include <compare> #include <complex> #include <concepts> #include <cstdarg> #include <cstddef> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <initializer_list> #include <iomanip> #include <ios> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <map> #include <memory> #include <new> #include <numbers> #include <numeric> #include <ostream> #include <queue> #include <random> #include <ranges> #include <set> #include <span> #include <sstream> #include <stack> #include <streambuf> #include <string> #include <tuple> #include <type_traits> #include <variant> //#define int ll #define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1) #define INT128_MIN (-INT128_MAX - 1) #define clock chrono::steady_clock::now().time_since_epoch().count() #ifdef DEBUG #define dbg(x) cout << (#x) << " = " << x << '\n' #else #define dbg(x) #endif namespace R = std::ranges; namespace V = std::views; using namespace std; using ll = long long; using ull = unsigned long long; using ldb = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; //#define double ldb template<class T> ostream& operator<<(ostream& os, const pair<T, T> pr) { return os << pr.first << ' ' << pr.second; } template<class T, size_t N> ostream& operator<<(ostream& os, const array<T, N> &arr) { for(const T &X : arr) os << X << ' '; return os; } template<class T> ostream& operator<<(ostream& os, const vector<T> &vec) { for(const T &X : vec) os << X << ' '; return os; } template<class T> ostream& operator<<(ostream& os, const set<T> &s) { for(const T &x : s) os << x << ' '; return os; } signed main() { ios::sync_with_stdio(false), cin.tie(NULL); int n, k; cin >> n >> k; vector<int> a(n + 1); for(int &x : a | V::drop(1)) cin >> x; vector<int> b = a; for(int i = 1; i <= n; i++) b[i] ^= b[i - 1]; int l = 0; { bitset<1 << 20> vis = {}; vis[b[0]] = true; while(l + 1 <= n and !vis[b[l + 1]]) vis[b[l + 1]] = true, l += 1; } int r = n; { bitset<1 << 20> vis = {}; vis[b[n]] = true; while(r > 0 and !vis[b[r - 1]]) vis[b[r - 1]] = true, r -= 1; } vector<int> cand; { bitset<1 << 21> bs = {}; for(int i = 1; i <= 1000000; i++) for(int j = max(i - 100, 1); j <= i + 100; j++) bs[i ^ j] = true; for(int i = 0; i < (1 << 21); i++) if (bs[i]) cand.emplace_back(i); } bool ans = false; for(int x : cand) { int lcnt[1 << 20] = {}, rcnt[1 << 20] = {}; for(int x : b) lcnt[x]++; if (*max_element(lcnt, lcnt + (1 << 20)) <= 1) ans = true; int count = 0; for(int i = n; i >= r; i--) { lcnt[b[i]]--; count -= rcnt[b[i]]; rcnt[b[i] ^ x]++; count += lcnt[b[i] ^ x]; if (i <= l + 1 and a[i] != x and abs((a[i] ^ x) - a[i]) <= k and count == 0) ans = true; } } cout << (ans ? "Yes\n" : "No\n"); return 0; }