結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー codershifthcodershifth
提出日時 2016-01-14 00:47:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 446 ms / 5,000 ms
コード長 1,311 bytes
コンパイル時間 1,246 ms
コンパイル使用メモリ 149,368 KB
実行使用メモリ 5,016 KB
最終ジャッジ日時 2023-09-17 17:26:48
合計ジャッジ時間 9,919 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 306 ms
4,836 KB
testcase_09 AC 57 ms
4,376 KB
testcase_10 AC 227 ms
4,380 KB
testcase_11 AC 158 ms
4,376 KB
testcase_12 AC 362 ms
4,760 KB
testcase_13 AC 391 ms
4,796 KB
testcase_14 AC 214 ms
4,380 KB
testcase_15 AC 428 ms
4,944 KB
testcase_16 AC 351 ms
4,816 KB
testcase_17 AC 380 ms
4,720 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 13 ms
4,892 KB
testcase_21 AC 446 ms
4,824 KB
testcase_22 AC 444 ms
4,900 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 253 ms
4,380 KB
testcase_29 AC 363 ms
5,016 KB
testcase_30 AC 309 ms
4,824 KB
testcase_31 AC 261 ms
4,380 KB
testcase_32 AC 332 ms
4,668 KB
testcase_33 AC 431 ms
4,792 KB
testcase_34 AC 425 ms
5,000 KB
testcase_35 AC 439 ms
4,792 KB
testcase_36 AC 437 ms
4,812 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;

int 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]);

        int k = 0;
        while (!pque.empty())
        {
            auto x = pque.top();
            pque.pop();
            ++k;
            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 k;
}
class HappyXorHard
{
public:
    void solve(void) {
        int N;
        cin>>N;
        vector<ull> A(N);
        REP(i,N) cin>>A[i];

        cout<<(1LL<<sweep_ull(A))<<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