結果
| 問題 |
No.2895 Zero XOR Subset
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-20 21:58:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 859 bytes |
| コンパイル時間 | 2,197 ms |
| コンパイル使用メモリ | 202,640 KB |
| 最終ジャッジ日時 | 2025-02-24 10:08:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 |
ソースコード
#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;
}