QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#155676#4810. Add OneInsert_Username_HereWA 1ms3680kbC++201.1kb2023-09-02 00:18:022023-09-02 00:18:02

Judging History

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

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

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 kms[62];
  for(int i = 0; i < 62; i++) kms[i] = basis[i];
  ll ans = bk + 1;
  for(ll i = 1; i < 62; i++) {
    for(int j = 0; j < 62; j++) basis[j] = 0;
    for(int j = 0; j < 62; j++) insert(kms[j] ^ (1 << i));
    if(find((1 << i) - 1)) ans = max(ans, bk ^ ((1 << (i + 1)) - 1));
  }
  cout << ans << "\n";
}

詳細信息

Test #1:

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

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

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

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

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

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

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

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

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

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

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

input:

6
56 90 61 63 56 23

output:

112

result:

ok 1 number(s): "112"

Test #8:

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

input:

7
8 83 78 19 36 6 22

output:

205

result:

ok 1 number(s): "205"

Test #9:

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

input:

7
23 23 22 78 2 29 88

output:

32

result:

ok 1 number(s): "32"

Test #10:

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

input:

7
109 80 14 27 9 45 24

output:

235

result:

ok 1 number(s): "235"

Test #11:

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

input:

7
144 152 137 143 145 139 183

output:

220

result:

ok 1 number(s): "220"

Test #12:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

7
189 270 119 372 240 144 153

output:

74

result:

wrong answer 1st numbers differ - expected: '78', found: '74'