QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155672#4810. Add OneInsert_Username_HereWA 1ms3572kbC++20951b2023-09-02 00:09:462023-09-02 00:09:46

Judging History

你现在查看的是最新测评结果

  • [2023-09-02 00:09:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2023-09-02 00:09:46]
  • 提交

answer

#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
// Cope Counter = at least 142

ll basis[62];

void insert(ll val) {
  for(ll i = 0; i < 62; i++) {
    if((val & (1ll << i)) == 0) continue;
    if(!basis[i]) {
      basis[i] = val;
      return;
    }
    val ^= basis[i];
  }
}
bool find(ll val) {
  for(ll i = 0; i < 62; i++) {
    if((val & (1ll << i)) == 0) continue;
    if(!basis[i]) return 0;
    val ^= basis[i];
  }
  return 1;
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
  for(int i = 0; i < 62; i++) basis[i] = 0;
  ll n;
  cin >> n;
  ll cur, bk = 0;
  for(ll i = 0; i < n; i++) {
    cin >> cur;
    bk ^= cur;
    insert(cur);
  }
  ll ans = 0;
  for(ll i = 1; i < 62; i++) {
    if(find((1ll << i) - 1)) ans = max(ans, bk ^ ((1ll << (i + 1)) - 1));
  }
  cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3436kb

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3444kb

input:

6
56 90 61 63 56 23

output:

64

result:

wrong answer 1st numbers differ - expected: '112', found: '64'