結果
問題 | No.2895 Zero XOR Subset |
ユーザー |
![]() |
提出日時 | 2024-09-18 23:50:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 642 ms |
コンパイル使用メモリ | 75,104 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 21:53:08 |
合計ジャッジ時間 | 3,013 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:21:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 21 | for(auto [base, ind]: basis){ | ^
ソースコード
#include <iostream>#include <vector>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int n;cin >> n;vector<long long> a(n);for(int i = 0; i < n; i++){cin >> a[i];}vector<pair<long long, long long>> basis;for(int i = 0; i < n; i++){long long value = a[i];long long index = (1LL << i);for(auto [base, ind]: basis){if((value ^ base) < value){value ^= base;index ^= ind;}}if(value == 0){vector<int> ans;for(int j = 0; j <= 60; j++){if(index & (1LL << j)){ans.emplace_back(j + 1);}}cout << ans.size() << endl;for(int b: ans){cout << b << " ";}cout << endl;return 0;}basis.emplace_back(value, index);}cout << -1 << endl;}