結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー bokusunnybokusunny
提出日時 2022-03-13 17:59:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 824 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 203,484 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:57:00
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 36 ms
4,348 KB
testcase_09 AC 10 ms
4,348 KB
testcase_10 AC 28 ms
4,348 KB
testcase_11 AC 21 ms
4,348 KB
testcase_12 AC 43 ms
4,348 KB
testcase_13 AC 45 ms
4,348 KB
testcase_14 AC 27 ms
4,348 KB
testcase_15 AC 50 ms
4,348 KB
testcase_16 AC 42 ms
4,348 KB
testcase_17 AC 44 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 10 ms
4,348 KB
testcase_21 AC 51 ms
4,348 KB
testcase_22 AC 51 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 31 ms
4,348 KB
testcase_29 AC 43 ms
4,348 KB
testcase_30 AC 38 ms
4,348 KB
testcase_31 AC 33 ms
4,348 KB
testcase_32 AC 40 ms
4,348 KB
testcase_33 AC 49 ms
4,348 KB
testcase_34 AC 49 ms
4,348 KB
testcase_35 AC 50 ms
4,348 KB
testcase_36 AC 50 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define bokusunny ios::sync_with_stdio(false), cin.tie(nullptr);

template <class T>
int GaussJordan_XOR(vector<T> &A) {
  int N = (int)A.size();
  int rank = 0;
  for (int bit = 62; bit >= 0; bit--) {
    int pivot = -1;
    for (int i = rank; i < N; i++) {
      if (A[i] >> bit & 1) {
        pivot = i;
        break;
      }
    }
    if (pivot == -1) continue;

    for (int i = 0; i < N; i++) {
      if (i == pivot) continue;
      if (A[i] >> bit & 1) A[i] ^= A[pivot];
    }

    swap(A[rank], A[pivot]);
    rank++;
  }

  return rank;
}

void solve() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  auto rank = GaussJordan_XOR(A);
  cout << (1LL << rank) << endl;
}

int main() {
  bokusunny;
  solve();

  return 0;
}
0