只有70分,求大佬看一眼

P4570 [BJWC2011] 元素

@[XjascodoixjqoinOI](/user/389844) 问题不大,就是 d 数组也是要开 long long 的 那你的代码改的 AC 代码: ```cpp //Test #include <iostream> #include <algorithm> #include <cstdio> #include <cstdio> using namespace std; typedef long long LL; const int N = 64; struct Node { int val; LL id; bool operator<(const Node &t) const { return val < t.val; } }a[1010]; LL d[N]; int n; bool insert(LL x) { for (int i = 63; i >= 0; i -- ) { if (x >> i & 1) { if (d[i]) x ^= d[i]; else { d[i] = x; return true; } } } return false; } int main() { int res = 0; scanf("%d", &n); for (int i = 0; i < n; i ++ ) { cin >> a[i].id >> a[i].val; } sort(a, a + n); reverse(a, a + n); for (int i = 0; i < n; i ++ ) { if (insert(a[i].id)) res += a[i].val; } cout << res << endl; return 0; } ```
by _LPF_ @ 2021-03-22 00:17:34


@[_LPF_](/user/117941) 谢谢大佬!我只考虑了结果的范围,没考虑d数组,还是太年轻了啊
by XjascodoixjqoinOI @ 2021-03-22 16:50:29


|