結果
問題 | No.184 たのしい排他的論理和(HARD) |
ユーザー |
|
提出日時 | 2019-09-21 02:00:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 5,000 ms |
コード長 | 1,299 bytes |
コンパイル時間 | 1,558 ms |
コンパイル使用メモリ | 171,492 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:30:32 |
合計ジャッジ時間 | 4,591 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) #define ALL(v) (v).begin(),(v).end() #define CLR(t,v) memset(t,(v),sizeof(t)) template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";} template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;} template<class T>void chmin(T&a,const T&b){if(a>b)a=b;} template<class T>void chmax(T&a,const T&b){if(a<b)a=b;} int nextInt() { int x; scanf("%d", &x); return x;} // 01ベクトルのランクを求める int binary_matrix_rank(vector<ll> A) { const int N = A.size(); const int M = 62; auto at = [](const ll Ai, int j) -> int { return Ai >> (M - 1 - j) & 1; }; int s = 0; REP(j, M) { int p = -1; for (int i = s; i < N; i++) if (at(A[i], j)) { p = i; break; } if (p >= 0) { swap(A[s], A[p]); for (int i = s+1; i < N; i++) if (at(A[i], j)) A[i] ^= A[s]; s++; } } return s; } int main2() { int N = nextInt(); vector<ll> A(N); REP(i, N) cin >> A[i]; int r = binary_matrix_rank(A); ll ans = 1LL << r; cout << ans << endl; return 0; } int main() { #ifdef LOCAL for (;!cin.eof();cin>>ws) #endif main2(); return 0; }