結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー ks115
提出日時 2021-03-13 16:52:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 2,942 ms
コンパイル使用メモリ 194,028 KB
最終ジャッジ日時 2025-01-19 16:11:25
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i, 0, N) cin >> A[i];

    int rank = 0;
    for (int i = 60; i >= 0; i--) {
        REP(j, rank + 1, N) {
            if (A[j] & (1LL << i)) {
                swap(A[j], A[rank]);
                break;
            }
        }
        if (rank >= N || !(A[rank] & (1LL << i))) continue;

        REP(j, 0, N) if (j != rank && A[j] & (1LL << i)) A[j] ^= A[rank];
        rank++;
    }

    cout << (1LL << rank) << endl; 
    return 0;
}
0