QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113159#4446. Link is as bearTobo#AC ✓245ms3448kbC++20823b2023-06-16 15:56:352023-06-16 15:56:38

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-16 15:56:38]
  • 评测
  • 测评结果:AC
  • 用时:245ms
  • 内存:3448kb
  • [2023-06-16 15:56:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define mod 1'000'000'007

void solve()
{
    int n;
    cin >> n;
    vector<i64> s(64);
    while (n--)
    {
        i64 x;
        cin >> x;
        for (int j = 63; j >= 0; j--)
        {
            if (x >> j & 1)
            {
                if (s[j])
                    x ^= s[j];
                else
                {
                    s[j] = x;
                    x = 0;
                }
            }
        }
    }
    i64 ans = 0;
    for (int i = 63; i >= 0; i--)
        if ((ans ^ s[i]) > ans)
            ans ^= s[i];
    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 245ms
memory: 3448kb

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