結果
問題 | No.1304 あなたは基本が何か知っていますか?私は知っています. |
ユーザー | leafirby |
提出日時 | 2020-12-01 22:11:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 345 ms / 2,000 ms |
コード長 | 3,929 bytes |
コンパイル時間 | 2,578 ms |
コンパイル使用メモリ | 214,456 KB |
実行使用メモリ | 7,168 KB |
最終ジャッジ日時 | 2024-06-12 11:46:16 |
合計ジャッジ時間 | 23,702 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
6,812 KB |
testcase_01 | AC | 4 ms
6,940 KB |
testcase_02 | AC | 3 ms
6,944 KB |
testcase_03 | AC | 3 ms
6,940 KB |
testcase_04 | AC | 342 ms
6,944 KB |
testcase_05 | AC | 159 ms
6,940 KB |
testcase_06 | AC | 6 ms
6,940 KB |
testcase_07 | AC | 292 ms
6,940 KB |
testcase_08 | AC | 21 ms
6,944 KB |
testcase_09 | AC | 261 ms
6,940 KB |
testcase_10 | AC | 203 ms
6,944 KB |
testcase_11 | AC | 274 ms
6,940 KB |
testcase_12 | AC | 218 ms
6,940 KB |
testcase_13 | AC | 144 ms
6,940 KB |
testcase_14 | AC | 184 ms
6,940 KB |
testcase_15 | AC | 177 ms
6,944 KB |
testcase_16 | AC | 207 ms
6,944 KB |
testcase_17 | AC | 27 ms
6,944 KB |
testcase_18 | AC | 198 ms
6,940 KB |
testcase_19 | AC | 105 ms
6,940 KB |
testcase_20 | AC | 19 ms
6,944 KB |
testcase_21 | AC | 78 ms
7,168 KB |
testcase_22 | AC | 226 ms
6,940 KB |
testcase_23 | AC | 272 ms
6,940 KB |
testcase_24 | AC | 345 ms
6,944 KB |
testcase_25 | AC | 5 ms
6,940 KB |
testcase_26 | AC | 19 ms
6,940 KB |
testcase_27 | AC | 34 ms
6,944 KB |
testcase_28 | AC | 12 ms
6,940 KB |
testcase_29 | AC | 12 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 3 ms
6,944 KB |
testcase_32 | AC | 35 ms
6,940 KB |
testcase_33 | AC | 5 ms
6,944 KB |
testcase_34 | AC | 30 ms
6,940 KB |
testcase_35 | AC | 7 ms
6,940 KB |
testcase_36 | AC | 5 ms
6,940 KB |
testcase_37 | AC | 5 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 2 ms
6,940 KB |
testcase_40 | AC | 8 ms
6,940 KB |
testcase_41 | AC | 3 ms
6,940 KB |
testcase_42 | AC | 10 ms
6,940 KB |
testcase_43 | AC | 7 ms
6,944 KB |
testcase_44 | AC | 4 ms
6,944 KB |
04_evil_A_01 | RE | - |
04_evil_A_02 | RE | - |
04_evil_A_03 | RE | - |
04_evil_A_04 | RE | - |
04_evil_A_05 | RE | - |
04_evil_A_06 | RE | - |
04_evil_A_07 | RE | - |
04_evil_A_08 | RE | - |
04_evil_A_09 | RE | - |
04_evil_A_10 | RE | - |
05_evil_B_01 | RE | - |
05_evil_B_02 | RE | - |
05_evil_B_03 | RE | - |
05_evil_B_04 | RE | - |
05_evil_B_05 | RE | - |
05_evil_B_06 | RE | - |
05_evil_B_07 | RE | - |
05_evil_B_08 | RE | - |
05_evil_B_09 | RE | - |
05_evil_B_10 | RE | - |
06_evil_C_01 | MLE | - |
06_evil_C_02 | MLE | - |
06_evil_C_03 | MLE | - |
06_evil_C_04 | MLE | - |
06_evil_C_05 | MLE | - |
06_evil_C_06 | MLE | - |
06_evil_C_07 | MLE | - |
06_evil_C_08 | MLE | - |
06_evil_C_09 | MLE | - |
06_evil_C_10 | RE | - |
ソースコード
#include <bits/stdc++.h> #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define ll long long #define rep(i, m, n) for (ll i = m; i < n; i++) #define UE(N) N.erase(unique(N.begin(), N.end()), N.end()); #define Sort(n) sort(n.begin(), n.end()) #define mod 998244353 #define chmin(a, b) a = (((a) > (b)) ? (b) : (a)) template<typename U = unsigned, int B = 32> class lazy_binary_trie { struct node { int cnt; U lazy; node *ch[2]; node() : cnt(0), lazy(0), ch{ nullptr, nullptr } {} }; void push(node* t, int b) { if ((t->lazy >> (U)b) & (U)1) swap(t->ch[0], t->ch[1]); if (t->ch[0]) t->ch[0]->lazy ^= t->lazy; if (t->ch[1]) t->ch[1]->lazy ^= t->lazy; t->lazy = 0; } node* add(node* t, U val, int b = B - 1) { if (!t) t = new node; t->cnt += 1; if (b < 0) return t; push(t, b); bool f = (val >> (U)b) & (U)1; t->ch[f] = add(t->ch[f], val, b - 1); return t; } node* sub(node* t, U val, int b = B - 1) { assert(t); t->cnt -= 1; if (t->cnt == 0) return nullptr; if (b < 0) return t; push(t, b); bool f = (val >> (U)b) & (U)1; t->ch[f] = sub(t->ch[f], val, b - 1); return t; } U get_min(node* t, U val, int b = B - 1) { assert(t); if (b < 0) return 0; push(t, b); bool f = (val >> (U)b) & (U)1; f ^= !t->ch[f]; return get_min(t->ch[f], val, b - 1) | ((U)f << (U)b); } U get(node* t, int k, int b = B - 1) { if (b < 0) return 0; push(t, b); int m = t->ch[0] ? t->ch[0]->cnt : 0; return k < m ? get(t->ch[0], k, b - 1) : get(t->ch[1], k - m, b - 1) | ((U)1 << (U)b); } int count_lower(node* t, U val, int b = B - 1) { if (!t || b < 0) return 0; push(t, b); bool f = (val >> (U)b) & (U)1; return (f && t->ch[0] ? t->ch[0]->cnt : 0) + count_lower(t->ch[f], val, b - 1); } node *root; public: lazy_binary_trie() : root(nullptr) {} int size() const { return root ? root->cnt : 0; } bool empty() const { return !root; } void insert(U val) { root = add(root, val); } void erase(U val) { root = sub(root, val); } void xor_all(U val) { if (root) root->lazy ^= val; } U max_element(U bias = 0) { return get_min(root, ~bias); } U min_element(U bias = 0) { return get_min(root, bias); } int lower_bound(U val) { // return id return count_lower(root, val); } int upper_bound(U val) { // return id return count_lower(root, val + 1); } U operator[](int k) { assert(0 <= k && k < size()); return get(root, k); } int count(U val) { if (!root) return 0; node *t = root; for (int i = B - 1; i >= 0; i--) { push(t, i); t = t->ch[(val >> (U)i) & (U)1]; if (!t) return 0; } return t->cnt; } }; ll N, K; vector<ll> A, C(1024); vector<lazy_binary_trie<ll>> B(1024); void dfs(ll cnt, ll x, ll prev) { if(!cnt) { B[prev].insert(x); C[x]++; } else { rep(i, 0, K) { if(A[i] == prev) continue; dfs(cnt - 1, x ^ A[i], A[i]); } } } int main() { ios::sync_with_stdio(false); cin.tie(0); ll X, Y; cin >> N >> K >> X >> Y; A.resize(K); rep(i, 0, K) cin >> A[i]; Sort(A), UE(A); K = A.size(); dfs(N / 2, 0, -1); ll res = 0; rep(i, 0, 1024) rep(j, 0, 1024) { ll v = B[i].upper_bound(j) - B[i].lower_bound(j); B[i].xor_all(j); res += (B[i].upper_bound(Y) - B[i].lower_bound(X)) * (C[j] - v) % mod; B[i].xor_all(j); } cout << res % mod << endl; }