結果
| 問題 |
No.2895 Zero XOR Subset
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-20 22:51:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 967 bytes |
| コンパイル時間 | 2,338 ms |
| コンパイル使用メモリ | 212,280 KB |
| 最終ジャッジ日時 | 2025-02-24 10:33:43 |
|
ジャッジサーバーID (参考情報) |
judge2 / 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;
}