Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
39231 Gapple 【BJ】T1 C++ 解答错误 60 147 MS 272 KB 1933 2025-12-27 15:58:40

Tests(17/28):


#include <algorithm> #include <iostream> 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 x, y, z; cin >> x >> y >> z; cout << max({ x + y + z, 2 * (x ^ y) + z, x + 2 * (y ^ z), 3 * (x ^ z), 3 * x, 3 * z }) << '\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; }


测评信息: