洛谷 - P3812

本文最後更新於:2025年8月2日 凌晨

洛谷 - P3812

luogu-P3812.cpp

// Author : ysh
// 2025/08/01 Fri 23:26:14
// https://www.luogu.com.cn/problem/P3812
#include<bits/stdc++.h>
using namespace std;
#include<slow>
#define R 51
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;cin>>n;
    vc<long long>f(n);
    cin>>f;

    vc<long long>mark(R);
    repo(&i, f) {
        for(int j = R - 1; j >= 0; j--) {
            if(!(i & (1LL << j))) continue;
            if(mark.at(j) == 0) {
                mark.at(j) = i;
                break;
            } else {
                i ^= mark.at(j);
            }
        }
    }

    long long ans = 0;
    for(int i = R - 1; i >= 0; i--) {
        if(ans & (1LL << i)) continue;
        ans = ans ^ mark.at(i);
    }

    out(ans);
    return 0;
}

洛谷 - P3812
http://mysh212.github.io/algosolution/luogu-P3812.cpp/
作者
ysh
發布於
2025年8月1日
更新於
2025年8月2日
許可協議