結果

問題 No.231 めぐるはめぐる (1)
ユーザー codershifthcodershifth
提出日時 2016-01-16 14:18:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,523 bytes
コンパイル時間 1,347 ms
コンパイル使用メモリ 162,960 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 00:05:03
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

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

using namespace std;

// uint64_t 吐き出し法
std::vector<uint64_t>
sweep_uint64(const std::vector<uint64_t> &A)
{
        auto a = A;
        int  n = a.size();

        int row = 0;
        // O(64*N)
        for (int col = 63; col >= 0; --col)
        {
            int pivot = row; //row 行目以降だけ見る
            // 先頭から col 番目のビットが立っている a[i] を見つける
            while ( pivot < n && !(a[pivot] & 1ULL<<col) )
                ++pivot;
            // col 番目にビットが立つ a はなかった
            if (pivot == n)
                continue;

            swap(a[row], a[pivot]);
            for (int i = row+1; i < n; ++i)
            {
                if ( a[i] & 1ULL<<col)
                    a[i] ^= a[row];
            }
            ++row;
        }
        return a;
}

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

        A = sweep_uint64(A);

        int k = count_if(RANGE(A), [](uint64_t 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