QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#53199#4446. Link is as bearlqhsmashAC ✓329ms4524kbC++915b2022-10-04 19:55:262022-10-04 19:55:34

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-04 19:55:34]
  • 评测
  • 测评结果:AC
  • 用时:329ms
  • 内存:4524kb
  • [2022-10-04 19:55:26]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 1e5 + 50;

int T = 1;
int n;
ll a[N], d[70];

void add (ll x) {
    for (int i = 63; i >= 0; i --) {
        if (x >> i & 1) {
            if (d[i]) x ^= d[i];
            else {
                d[i] = x;
                break;
            }
        }
    }
}

ll ask_max () {
    ll ans = 0;
    for (int i = 63; i >= 0; i --) 
        if ((ans ^ d[i]) > ans) 
            ans ^= d[i];
    return ans;
}

void solve () {
    scanf ("%d", &n);
    for (int i = 1; i <= n; i ++) scanf ("%lld", &a[i]);
    memset (d, 0, sizeof (d));
    for (int i = 1; i <= n; i ++) add (a[i]);
    printf("%lld\n", ask_max ());
}

int main() {
    // freopen ("in.in", "r", stdin);
    // freopen ("out.out", "w", stdout);
    scanf ("%d", &T);
    while (T --) {
        solve ();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 329ms
memory: 4524kb

input:

22222
100000
595189703884863 72716684812661 449525802123580 504421888022388 390139608591346 108895143840760 170477720052912 185583843894744 201608404318832 128831549357316 521084715261656 668960191579878 573530403227342 489014525501629 56366633717911 1705111713690 227582321537214 710815946393065 169...

output:

1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
1125899906842623
11258999068...

result:

ok 22222 lines