結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー tkzw_21
提出日時 2015-04-17 19:00:20
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 627 bytes
コンパイル時間 1,120 ms
コンパイル使用メモリ 159,904 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-04 11:34:30
合計ジャッジ時間 4,011 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    
    long long r = 0;
    for(int i=0;i<61;i++){
        int t = -1;
        for(int j=r;j<n;j++){
            if((1LL<<i) & a[j]){
                t = j;
                break;
            }
        }
        if(t == -1)continue;
        swap(a[r],a[t]);
        for(int j=r+1;j<n;j++){
            if(r != j){
                if(a[j] & (1LL<<i))a[j] ^= a[r];
            }
        }
        r++;
    }
    cout << (1LL<<r) << endl;
    
    return 0;
}
0