QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#113218#4446. Link is as bearLiuf#AC ✓139ms4340kbC++20835b2023-06-16 18:07:432023-06-16 18:07:46

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 18:07:46]
  • 评测
  • 测评结果:AC
  • 用时:139ms
  • 内存:4340kb
  • [2023-06-16 18:07:43]
  • 提交

answer

#include<bits/stdc++.h>

#define endl '\n'
#define pii pair<int, int>
#define int long long
#define ld long double
#define ull unsigned long long

using namespace std;

const int mod=1e9+7,M=2000010,Mlog=22;

vector<ull>B;
void insert(ull x){
    for(auto b:B){
        x=min(x,b^x);
    }
    for(auto &b:B){
        b=min(b,b^x);
    }
    if(x){
        B.push_back(x);
    }
}

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

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

    int ans=0;
    for(int x:B){
        ans^=x;
    }

    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;

    while(t--){
        solve();
    }



    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 139ms
memory: 4340kb

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