結果
問題 | No.2895 Zero XOR Subset |
ユーザー |
|
提出日時 | 2024-09-20 21:57:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,660 bytes |
コンパイル時間 | 1,961 ms |
コンパイル使用メモリ | 182,732 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-20 21:57:52 |
合計ジャッジ時間 | 4,716 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:28:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 28 | for(auto [b, j] : B){ | ^
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;#define all(a) (a).begin(), (a).end()#define pb push_back#define fi first#define se secondmt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());const ll MOD1000000007 = 1000000007;const ll MOD998244353 = 998244353;const ll MOD[3] = {999727999, 1070777777, 1000000007};const ll LINF = 1LL << 60LL;const int IINF = (1 << 30) - 2;void solve(){int n; cin >> n;vector<ll> A(n);for(int i=0; i<n; i++) cin >> A[i];n = min(n, 61);vector<vector<bool>> used(n, vector<bool>(n, false));vector<pair<ll, int>> B;for(int i=0; i<n; i++){ll now = A[i];used[i][i] = true;for(auto [b, j] : B){if((now^b) < now){used[i][j] = true;now = now^b;}}if(now==0){vector<vector<bool>> cnt(i+1, vector<bool>(i+1, false));for(int j=0; j<=i; j++){for(int k=0; k<j; k++) if(used[j][k]){for(int l=0; l<n; l++) cnt[j][l] = cnt[j][l] ^ cnt[k][l];}cnt[j][j] = true;}vector<int> ans;for(int j=0; j<=i; j++) if(cnt[i][j]) ans.pb(j);cout << (int)ans.size() << '\n';for(int j : ans) cout << j+1 << ' ';cout << '\n';return;}else{used[i][i] = true;B.pb({now, i});}}cout << -1 << '\n';}int main(){cin.tie(nullptr);ios::sync_with_stdio(false);int T=1;//cin >> T;while(T--) solve();}