結果
| 問題 | No.2895 Zero XOR Subset |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-20 22:34:51 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,130 bytes |
| 記録 | |
| コンパイル時間 | 2,387 ms |
| コンパイル使用メモリ | 204,928 KB |
| 最終ジャッジ日時 | 2025-02-24 10:27:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | MLE * 1 -- * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void solve() {
ll n;
cin >> n;
vector<vector<ll>> a(n), b(n);
rep(i, n) {
ll x;
cin >> x;
rep(j, 60) a[i].push_back((x >> j) & 1);
b[i].push_back(i);
}
vector<bool> used(n, false);
rep(j, 60) {
ll k = -1;
rep(i, n) {
if (!used[i] && a[i][j]) {
k = i;
used[k] = true;
break;
}
}
if (k == -1)
continue;
rep(i, n) {
if (!used[i] && a[i][j]) {
rep(j2, 60) a[i][j2] ^= a[k][j2];
for (const auto x : b[k]) {
b[i].push_back(x);
}
}
}
}
rep(k, n) {
ll cnt = 0;
rep(j, 60) cnt += a[k][j];
if (cnt > 0)
continue;
sort(b[k].begin(), b[k].end());
cout << b[k].size() << '\n';
rep(i, b[k].size()) cout << (i ? " " : "") << b[k][i] + 1;
cout << '\n';
return;
}
cout << "-1\n";
}
int main() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
int T = 1;
for (int t = 0; t < T; t++) {
solve();
}
return 0;
}