結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
![]() |
提出日時 | 2020-08-14 04:29:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 997 bytes |
コンパイル時間 | 2,262 ms |
コンパイル使用メモリ | 194,896 KB |
最終ジャッジ日時 | 2025-01-12 22:22:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 12 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for(int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 #define MAX_RANK 60 ll hakidashi(vector<ll> a){ int n = a.size(); ll rank = 0; int j = 0; for (int i = MAX_RANK - 1; i >= 0; i--) { for (j = rank; j < n; j++) { if (a[j] & (1LL << i)) break; } if (j == n) { continue; } if (j > rank) a[rank] ^= a[j]; for (j = rank + 1; j < n; j++) { a[j] = min(a[j], a[j] ^ a[rank]); } rank++; } ll x = 0; for (int i = 0; i < n; i++) { x = max(x, x ^ a[i]); } return x; } int main(void){ int n; cin >> n; vector<ll> a(n); rep(i,n)cin >> a[i]; ll ans = hakidashi(a); int cnt = 0; while(ans > 0){ cnt += ans%2; ans/=2; } cout << (1LL<<cnt) << endl; return 0; }