結果
| 問題 |
No.2895 Zero XOR Subset
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-20 21:34:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 1,428 bytes |
| コンパイル時間 | 3,144 ms |
| コンパイル使用メモリ | 261,348 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-20 21:34:58 |
| 合計ジャッジ時間 | 5,793 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 35 |
ソースコード
// #include <bits/allocator.h> // Temp fix for gcc13 global pragma
// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
#ifdef LOCAL
#include "Debug.h"
#else
#define debug_endl() 42
#define debug(...) 42
#define debug2(...) 42
#define debugbin(...) 42
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int n;
cin >> n;
vector<long long> a(n);
copy_n(istream_iterator<long long>(cin), n, a.begin());
n = min(n, 61);
vector<long long> basis;
for(auto bit = 0; bit < 60; ++ bit){
long long x = 0;
for(auto i = 0; i < n; ++ i){
x |= (a[i] >> bit & 1) << i;
}
for(auto &b: basis){
x = min(x, b ^ x);
}
if(x == 0){
continue;
}
for(auto &b: basis){
b = min(b, b ^ x);
}
basis.push_back(x);
}
if((int)basis.size() == n){
cout << "-1\n";
return 0;
}
long long pivot = 0;
for(auto &b: basis){
pivot |= 1LL << __lg(b);
}
for(auto i = 0; i < n; ++ i){
if(pivot >> i & 1){
continue;
}
vector<int> res{i};
for(auto &b: basis){
if(b >> i & 1){
res.push_back(__lg(b));
}
}
ranges::sort(res);
cout << (int)res.size() << "\n";
for(auto i: res){
cout << i + 1 << " ";
}
cout << "\n";
return 0;
}
assert(false);
return 0;
}
/*
*/