結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー なおなお
提出日時 2015-04-17 00:05:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,651 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 154,300 KB
実行使用メモリ 734,324 KB
最終ジャッジ日時 2023-09-17 16:24:17
合計ジャッジ時間 10,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 73 ms
9,532 KB
testcase_05 AC 137 ms
9,564 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 289 ms
9,616 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define FOR(i, f, t)        for(int(i)=(f);(i)<(t);(++i))
#define RREP(i, n)          for(int(i)=(n)-1;(i)>=0;--(i))
const int MOD = int(1e9+7);

int N;
ll A[5555];

class uf_ {
public:
    vector<int> node;
    uf_(int n) : node(n, -1){;}
    void con(int n, int m){
        n = root(n); m = root(m); if(n == m) return;
        node[n] += node[m]; node[m] = n;
    }
    bool is_con(int n, int m){ return root(n) == root(m); }
    int root(int n){ return (node[n] < 0) ? n : node[n] = root(node[n]); }
    int size(int n){ return -node[root(n)]; }
};

bool f[66];

int main(){
    do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0);
    cin >> N;
    REP(i,N) cin >> A[i];

    uf_ uf(62);

    REP(i,N){
        ll a = A[i];
        int k = 0;
        REP(j,61){
            if((a>>j)&1){ k = j; break; }
        }
        FOR(j,k+1,61) if((a>>j)&1) uf.con(k,j);
    }

    ll res = 1;
    REP(i,61){
        int k = uf.root(i);
        if(f[k]) continue;
        f[k] = true;

        ll mask = 0;
        REP(j,61){
            if(!uf.is_con(i,j)) continue;
            mask |= 1LL<<j;
        }
        set<ll> s; s.insert(0);
        REP(j,N){
            ll a = A[j]&mask;
            set<ll> t;
            for(auto it = s.begin(); it != s.end(); ++it){
                t.insert(*it ^ a);
            }
            s.insert(t.begin(), t.end());
        }
        res *= s.size();
    }

    cout << res << endl;
    return 0;
}
0