QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#46093#4446. Link is as bearmiaomiaoziAC ✓309ms4376kbC++171.3kb2022-08-25 17:26:512022-08-25 17:26:52

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-25 17:26:52]
  • 评测
  • 测评结果:AC
  • 用时:309ms
  • 内存:4376kb
  • [2022-08-25 17:26:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917

#ifndef LOCAL
#define LOG(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long LL;
typedef pair <int, int> PII;

constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1);

int multi_cases = 1;

void A_SOUL_AvA () {
    int n;
    cin >> n;

    vector <LL> p(66);
    auto insert = [&](LL x) {
        for (int i = 60; i >= 0; i--) {
            if (x >> i & 1) {
                if (!p[i]) {
                    p[i] = x;
                    break;
                } else {
                    x ^= p[i];
                }
            }
        }
    };

    vector <LL> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        insert(a[i]);
    }

    LL ans = 0;
    for (int i = 60; i >= 0; i--) {
        if (!(ans >> i & 1)) {
            ans ^= p[i];
        }
    }

    cout << ans << endl;
}

int main () {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int T = 1;
    for (multi_cases && cin >> T; T; T--) {
        A_SOUL_AvA ();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 309ms
memory: 4376kb

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