結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー codershifthcodershifth
提出日時 2016-01-14 00:29:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 410 ms / 5,000 ms
コード長 1,735 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 150,456 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-09-17 17:24:45
合計ジャッジ時間 9,349 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 280 ms
4,764 KB
testcase_09 AC 52 ms
4,380 KB
testcase_10 AC 208 ms
4,376 KB
testcase_11 AC 145 ms
4,380 KB
testcase_12 AC 330 ms
4,876 KB
testcase_13 AC 362 ms
5,088 KB
testcase_14 AC 196 ms
4,380 KB
testcase_15 AC 394 ms
5,000 KB
testcase_16 AC 323 ms
4,876 KB
testcase_17 AC 350 ms
4,724 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 13 ms
4,820 KB
testcase_21 AC 409 ms
5,012 KB
testcase_22 AC 410 ms
4,804 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 231 ms
4,380 KB
testcase_29 AC 330 ms
4,700 KB
testcase_30 AC 284 ms
4,760 KB
testcase_31 AC 240 ms
4,380 KB
testcase_32 AC 304 ms
5,064 KB
testcase_33 AC 394 ms
4,916 KB
testcase_34 AC 392 ms
4,980 KB
testcase_35 AC 402 ms
4,876 KB
testcase_36 AC 401 ms
4,788 KB
権限があれば一括ダウンロードができます

ソースコード

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;
            while(!pque.empty())
            {
                auto y =pque.top();
                if ( __builtin_clzl(y) != __builtin_clzl(x) )
                    break;
                pque.pop();
                y ^= x;
                if (y > 0)
                    pque.push(y);
            }
        }
        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));

        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