結果
問題 |
No.2895 Zero XOR Subset
|
ユーザー |
![]() |
提出日時 | 2024-09-27 21:01:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 1,816 ms |
コンパイル使用メモリ | 163,084 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-27 21:02:05 |
合計ジャッジ時間 | 7,879 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 21 |
ソースコード
#include <bits/stdc++.h> #define int long long #define x first #define y second #define pi acos(-1) using namespace std; using LL = long long; using ULL = unsigned long long; typedef pair<int, int> PII; const int N = 1e6 + 10, M = 5010, mod = 1e9 + 7; void solve() { int n; cin >> n; vector <int> a(n + 1); int p = 0; for(int i = 1; i <= n; i++){ cin >> a[i]; if(a[i] == 0){ p = i; } } if(p != 0){ cout << 1 << "\n"; cout << p << "\n"; return; } /* ?B????????bit???????? ??bit???????2??? ???? ????bit?????1 ?????????????? ????????? ??????????????????? ? ????? ? 7 3 6 1 2 4 1 2 2 4 ???! ??? */ vector <PII> d(61); auto add = [&](int x, int y)->void{ for(int i = 59; i >= 0; i--){ if((x >> i) & 1){ if(d[i].x) x ^= d[i].x; else{ d[i].x = x; d[i].y = y; break; } } } return; }; for(int i = 1; i <= n; i++){ add(a[i], i); } int cnt = 0; for(int i = 0; i < 60; i++){ if(d[i].x != 0) cnt++; } if(cnt == 1 || cnt == n){ cout << -1 << "\n"; }else{ cout << cnt + 1 << "\n"; int res = 0; for(int i = 0; i < 60; i++){ if(d[i].x) cout << d[i].y << " ", res ^= d[i].x; } for(int i = 1; i <= n; i++){ if(a[i] == res) cout << i << "\n"; } } } signed main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int T = 1; //cin >> T; while(T--) { solve(); } }