Loading... Acwing 3488 其实就多加了个标记的集合 ```cpp #include <bits/stdc++.h> using namespace std; const int N = 35 * 1e5 + 10; int trie[N][2], cnt[N], s[N], n, m, idx; void insert(int x, int k){ int p = 0; for (int i = 30; i >= 0; i--) { int u = x >> i & 1; if (!trie[p][u]) trie[p][u] = ++ idx; p = trie[p][u]; cnt[p] += k; } } int query(int x){ int p = 0, res = 0; for (int i = 30; i >= 0; i--){ int u = x >> i & 1; if (cnt[trie[p][!u]]) p = trie[p][!u], (res <<= 1) += 1; else p = trie[p][u], res <<= 1; } return res; } int main(){ cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i]; s[i] ^= s[i - 1]; } insert(0, 1); int res = 0; for (int i = 1; i <= n; i++) { if (i > m) insert((i - m - 1), -1); res = max(query(s[i]), res); insert(s[i], 1); } cout << res; return 0; } ``` Last modification:February 26, 2023 © Allow specification reprint Like 0 如果觉得我的文章对你有用,请随意赞赏
Comment here is closed