結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー yukudoyukudo
提出日時 2019-09-21 02:00:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 1,299 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 167,928 KB
実行使用メモリ 4,972 KB
最終ジャッジ日時 2023-09-17 17:56:15
合計ジャッジ時間 4,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 72 ms
4,384 KB
testcase_09 AC 16 ms
4,380 KB
testcase_10 AC 55 ms
4,380 KB
testcase_11 AC 40 ms
4,376 KB
testcase_12 AC 82 ms
4,472 KB
testcase_13 AC 90 ms
4,472 KB
testcase_14 AC 52 ms
4,376 KB
testcase_15 AC 97 ms
4,616 KB
testcase_16 AC 81 ms
4,380 KB
testcase_17 AC 87 ms
4,400 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 21 ms
4,668 KB
testcase_21 AC 100 ms
4,668 KB
testcase_22 AC 100 ms
4,676 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 60 ms
4,380 KB
testcase_29 AC 86 ms
4,396 KB
testcase_30 AC 75 ms
4,380 KB
testcase_31 AC 64 ms
4,380 KB
testcase_32 AC 80 ms
4,424 KB
testcase_33 AC 98 ms
4,724 KB
testcase_34 AC 96 ms
4,972 KB
testcase_35 AC 99 ms
4,680 KB
testcase_36 AC 99 ms
4,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0