結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー codershifthcodershifth
提出日時 2016-01-14 00:24:41
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,717 bytes
コンパイル時間 3,214 ms
コンパイル使用メモリ 151,568 KB
実行使用メモリ 7,908 KB
最終ジャッジ日時 2023-09-17 17:25:35
合計ジャッジ時間 14,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

std::vector<unsigned long long> sweep_ull(std::vector<unsigned long long> A)
{
        int n = A.size();
        std::priority_queue<unsigned long long> pque;
        for (int i = 0; i < n; ++i)
            pque.push(A[i]);

        std::vector<unsigned long long> ret;
        while (!pque.empty())
        {
            auto x = pque.top();
            pque.pop();
            ret.push_back(x);
            if (pque.empty())
                break;
            auto y =pque.top();
            while ( __builtin_clzl(y) == __builtin_clzl(x) )
            {
                pque.pop();
                y ^= x;
                pque.push(y);
                y = pque.top();
            }
        }
        return ret;
}
unsigned long long mpow(unsigned long long a, int k)
{
        unsigned long long  b = 1;
        while (k > 0)
        {
            if (k & 1)
                b = (b*a);
            a = (a*a);
            k >>= 1;
        }
        return b;
}

class HappyXorHard
{
public:
    void solve(void) {
        int N;
        cin>>N;
        vector<ull> A(N);
        REP(i,N) cin>>A[i];

        A = sweep_ull(move(A));
        REP(i,N)cerr<<bitset<64>(A[i])<<endl;

        int k = count_if(RANGE(A), [](unsigned long long a) { return (a>0); });

        cout<<mpow((ull)2,k)<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new HappyXorHard();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0