結果
問題 | No.2895 Zero XOR Subset |
ユーザー |
|
提出日時 | 2024-09-20 22:51:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 1,159 bytes |
コンパイル時間 | 4,268 ms |
コンパイル使用メモリ | 256,552 KB |
最終ジャッジ日時 | 2025-02-24 10:34:17 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template<typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template<typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; int main(){ ll n; cin>>n; vector<ll> a(n); rep(i,0,n) cin>>a.at(i); vector<ll> b; vector<pair<ll,vector<ll>>> ck; rep(i,0,n){ ll x=a.at(i); vector<ll> v; ll ct=0; for(ll y:b){ if(chmin(x,x^y)) v.push_back(ct); ct++; } if(x==0){ vector<ll> ans; ans.push_back(i); ll m=b.size(); vector<ll> us(m,0); for(ll d:v) us.at(d)^=1; while(!us.empty()){ if(us.back()){ auto[dd,tv]=ck.back(); ans.push_back(dd); for(ll d:tv) us.at(d)^=1; } us.pop_back(); ck.pop_back(); } m=ans.size(); cout<<m<<"\n"; rep(j,0,m) cout<<ans.at(j)+1<<" \n"[j==m-1]; return 0; } b.push_back(x); ck.push_back({i,v}); } cout<<"-1\n"; }