結果
問題 |
No.2895 Zero XOR Subset
|
ユーザー |
![]() |
提出日時 | 2024-09-21 02:22:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,085 bytes |
コンパイル時間 | 2,193 ms |
コンパイル使用メモリ | 197,444 KB |
最終ジャッジ日時 | 2025-02-24 10:53:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using ll = std::int64_t; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N; std::cin >> N; std::vector<ll> basis, coef, pos; for(int i=0;i<N;i++){ ll A; std::cin >> A; ll c = 0; for(int j=0;j<basis.size();j++){ if((A ^ basis[j]) < A){ A ^= basis[j]; c ^= coef[j]; } } if(A > 0){ c |= 1ll << basis.size(); basis.emplace_back(A); coef.emplace_back(c); pos.emplace_back(i + 1); }else{ std::vector<ll> B; for(int j=0;j<basis.size();j++){ if(c >> j & 1){ B.emplace_back(pos[j]); } } B.emplace_back(i + 1); std::cout << B.size() << std::endl; for(int j=0;j<B.size();j++){ std::cout << B[j] << " \n"[j + 1 == B.size()]; } return 0; } } std::cout << -1 << std::endl; }