結果
| 問題 | No.2895 Zero XOR Subset |
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-11-13 14:42:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,582 bytes |
| コンパイル時間 | 2,136 ms |
| コンパイル使用メモリ | 204,932 KB |
| 最終ジャッジ日時 | 2025-02-25 04:04:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int BITLEN=60;
//bitsetの昇順
bool bitasc(const bitset<BITLEN> &a, const bitset<BITLEN> &b){
for (int i=BITLEN-1; i>=0; i--){
if (a[i] != b[i]){
return a[i] < b[i];
}
}
return false;
}
//bitsetのmin
bitset<BITLEN> min(bitset<BITLEN> a, bitset<BITLEN> b){
if (bitasc(a, b)) return a;
return b;
}
const ll modc=998244353;
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll N, A;
cin >> N;
vector<pair<bitset<BITLEN>, int>> vec(N);
vector<pair<bitset<BITLEN>, int>> base;
for (int i=0; i<N; i++){
cin >> A;
vec[i] = {A, i};
}
//A_iに作用したindex
vector<vector<ll>> v(N);
vector<ll> cnt(N), ans;
auto dfs=[&](auto self, int from)->void{
cnt[from]++;
for (auto to : v[from]){
self(self, to);
}
};
for (int i=0; i<N; i++){
for (auto &[e, x] : base){
if (bitasc(vec[i].first^e, vec[i].first)){
vec[i].first = vec[i].first^e;
v[i].push_back(x);
}
}
if (vec[i].first.any()) base.push_back(vec[i]);
else{
dfs(dfs, i);
for (int j=0; j<N; j++){
if (cnt[j] % 2 == 1) ans.push_back(j+1);
}
cout << ans.size() << endl;
for (auto x : ans) cout << x << " ";
cout << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}
srjywrdnprkt