結果
問題 | No.2895 Zero XOR Subset |
ユーザー |
![]() |
提出日時 | 2024-10-08 20:44:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 964 bytes |
コンパイル時間 | 1,959 ms |
コンパイル使用メモリ | 199,108 KB |
最終ジャッジ日時 | 2025-02-24 17:04:11 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define ALL(v) v.begin(),v.end()#define dbg(x) cerr << #x << ": " << (x) << endl;int n;vector<ll> a;int main() {cin >> n;a.resize(n);for (int i = 0; i < n; ++i) cin >> a[i];vector<pair<ll,ll>> bases;for (int i = 0; i < n; ++i) {ll y = a[i];ll mask = 1LL << i;for (auto [b,index] : bases) {if ((b ^ y) < y) {y ^= b;mask ^= index;}}if (y) {bases.emplace_back(y, mask);}else {vector<int> v;for (int j = 0; j <= 60; ++j) if (mask >> j & 1) {v.push_back(j);}cout << v.size() << '\n';for (int j = 0; j < v.size(); ++j) {cout << v[j]+1 << " \n"[j==v.size()-1];}return 0;}}cout << -1 << '\n';}