結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー codershifthcodershifth
提出日時 2016-01-14 00:43:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 402 ms / 5,000 ms
コード長 1,482 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 150,568 KB
実行使用メモリ 5,000 KB
最終ジャッジ日時 2023-09-17 17:25:55
合計ジャッジ時間 9,161 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 277 ms
4,696 KB
testcase_09 AC 51 ms
4,376 KB
testcase_10 AC 206 ms
4,380 KB
testcase_11 AC 143 ms
4,380 KB
testcase_12 AC 326 ms
4,884 KB
testcase_13 AC 355 ms
4,904 KB
testcase_14 AC 194 ms
4,380 KB
testcase_15 AC 387 ms
4,768 KB
testcase_16 AC 317 ms
4,868 KB
testcase_17 AC 343 ms
4,844 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 13 ms
4,964 KB
testcase_21 AC 402 ms
4,792 KB
testcase_22 AC 401 ms
4,888 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 229 ms
4,376 KB
testcase_29 AC 326 ms
4,692 KB
testcase_30 AC 280 ms
4,696 KB
testcase_31 AC 237 ms
4,380 KB
testcase_32 AC 300 ms
4,812 KB
testcase_33 AC 388 ms
4,784 KB
testcase_34 AC 384 ms
4,996 KB
testcase_35 AC 398 ms
4,844 KB
testcase_36 AC 396 ms
5,000 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;
}
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<<(1LL<<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