| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 39232 | Gapple | 【BJ】T1 | C++ | 编译错误 | 0 | 0 MS | 0 KB | 2480 | 2025-12-27 16:05:04 |
#include <algorithm> #include <iostream> #include <utility> using namespace std; using u64 = unsigned long long; struct LinearBasis { u64 basis[64]; LinearBasis() : basis { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } { } bool insert(u64 val) { for (int i = 63; i >= 0; --i) { if (~(val >> i) & 1) continue; if (basis[i] == 0) { basis[i] = val; return true; } else val ^= basis[i]; } return false; } u64 get_max() { u64 res = 0; for (int i = 63; i >= 0; --i) res = max(res, res ^ basis[i]); return res; } bool can_repr(u64 val) { for (int i = 63; i >= 0; --i) { if (~(val >> i) & 1) continue; if (basis[i] == 0) return true; else val ^= basis[i]; } return false; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; if (n == 1) { int x; cin >> x; cout << x << '\n'; } else if (n == 2) { int x, y; cin >> x >> y; cout << max(x + y, 2 * (x ^ y)) << '\n'; } else if (n == 3) { int a[3]; cin >> a[0] >> a[1] >> a[2]; u64 ans = u64(a[0]) + a[1] + a[2]; auto solve = [&](auto&& self, int steps) { ans = max(ans, u64(a[0]) + a[1] + a[2]); if (steps <= 0) return; for (int i = 0; i < 3; ++i) { for (int j = i + 1; j < 3; ++j) { int b[3] = { a[0], a[1], a[2] }; fill(b + i, b + j + 1, a[i] ^ a[j]); swap(a, b); self(self, steps - 1); swap(a, b); } } }; solve(solve, 15); cout << ans << '\n'; } else { LinearBasis basis; for (int i = 0; i < n; ++i) { int x; cin >> x; basis.insert(x); } cout << n * basis.get_max() << '\n'; } return 0; }