結果

問題 No.2895 Zero XOR Subset
ユーザー GOTKAKOGOTKAKO
提出日時 2024-09-20 21:58:37
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 2,616 ms
コンパイル使用メモリ 208,908 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 21:59:10
合計ジャッジ時間 4,374 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

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

random_device rnd;
mt19937 mt(rnd());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    vector<long long> A(N);
    for(auto &a : A) cin >> a;

    vector<pair<long long,long long>> base;
    for(int i=0; i<N; i++){
        long long a = A.at(i),now = 1LL<<i;
        for(auto [b,s] : base) if(a > (a^b)) a = a^b,now ^= s;
        if(a == 0){
            vector<int> answer;
            for(int k=0; k<63; k++) if(now&(1LL<<k)) answer.push_back(k+1);
            cout << answer.size() << endl;
            for(int k=0; k<answer.size(); k++) cout << answer.at(k) << (k+1==answer.size()?"\n":" ");
            return 0;
        }
        for(auto &[b,s] : base) if(b > (b^a)) b = b^a,s ^= now;
        base.push_back({a,now});
    }
    cout << "-1" << endl;
}
0