結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー yosupot
提出日時 2015-04-17 20:01:27
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 70,036 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-04 11:35:17
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <iostream>
#include <cassert>
#include <cstring>
#include <map>
#include <set>
using namespace std;

typedef long long ll;


const int MN = 100100;

ll a[MN];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    set<int> s;
    for (int i = 0; i < 62; i++) {
        int res = -1;
        for (int j = 0; j < n; j++) {
            if (!s.count(j) && a[j] & (1LL<<i)) {
                res = j;
                break;
            }
        }
        if (res == -1) continue;
        s.insert(res);
        for (int j = 0; j < n; j++) {
            if (j == res) continue;
            if (!(a[j] & (1LL<<i))) continue;
            a[j] ^= a[res];
        }
    }
    ll r = 1;
    for (int i = 0; i < (int)s.size(); i++) {
        r <<= 1;
    }
    cout << r << endl;
    return 0;
}
0