結果
問題 | No.2895 Zero XOR Subset |
ユーザー | karinohito |
提出日時 | 2024-09-20 22:51:40 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 2,810 ms |
コンパイル使用メモリ | 219,160 KB |
実行使用メモリ | 15,872 KB |
最終ジャッジ日時 | 2024-09-20 22:51:47 |
合計ジャッジ時間 | 5,834 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int N; cin>>N; vector<pair<ll,ll>> A(N); for(int i=0;i<N;i++){ cin>>A[i].first; A[i].second=i; } sort(A.begin(),A.end()); vector<map<ll,ll>> P(N); for(int i=0;i<N;i++){ P[i][i]=1; for(int j=0;j<i;j++){ if((A[j].first^A[i].first)<A[i].first){ A[i].first=(A[j].first^A[i].first); for(auto m:P[j]){ if(m.second==1)P[i][m.first]=1-P[i][m.first]; } } } if(A[i].first==0){ vector<ll> AN; for(auto m:P[i])if(m.second==1)AN.push_back(A[m.first].second+1); int an=AN.size(); cout<<an<<endl; for(int j=0;j<an;j++)cout<<AN[j]<<" \n"[j==an-1]; return 0; } } cout<<-1<<endl; }