結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,504 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 TLE -
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();
        for (int i = 0; i < N; ++i)
        {
            int pivot = i;
            for (int j = i+1; j < N; ++j)
            {
                if ( __builtin_clzl(A[j]) < __builtin_clzl(A[pivot]))
                    pivot = j;
            }
            if (pivot != i)
                swap(A[i], A[pivot]);

            for (int j = i+1; j < N; ++j)
            {
                if (__builtin_clzl(A[j]) == __builtin_clzl(A[i]))
                    A[j] ^= A[i];
            }
        }
        return A;
}
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