結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー chakkuchakku
提出日時 2016-03-31 03:46:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 518 ms / 5,000 ms
コード長 1,796 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 77,916 KB
実行使用メモリ 54,604 KB
最終ジャッジ日時 2023-09-17 17:29:22
合計ジャッジ時間 10,453 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 340 ms
39,536 KB
testcase_09 AC 50 ms
10,696 KB
testcase_10 AC 237 ms
30,708 KB
testcase_11 AC 147 ms
22,784 KB
testcase_12 AC 410 ms
45,532 KB
testcase_13 AC 452 ms
49,024 KB
testcase_14 AC 215 ms
29,524 KB
testcase_15 AC 474 ms
52,928 KB
testcase_16 AC 407 ms
44,476 KB
testcase_17 AC 446 ms
47,908 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 145 ms
54,524 KB
testcase_21 AC 515 ms
54,604 KB
testcase_22 AC 518 ms
54,472 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 255 ms
34,180 KB
testcase_29 AC 414 ms
47,144 KB
testcase_30 AC 348 ms
41,848 KB
testcase_31 AC 288 ms
36,692 KB
testcase_32 AC 381 ms
45,004 KB
testcase_33 AC 493 ms
53,344 KB
testcase_34 AC 489 ms
52,796 KB
testcase_35 AC 497 ms
54,560 KB
testcase_36 AC 502 ms
53,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define MP make_pair
#define PB push_back
#define ALL(v) (v).begin(),(v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int N;cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    sort(ALL(A));

    vector<vector<ll>> mat(N,vector<ll>(61,0));
    for(int i=0;i<N;i++){
        ll t = A[i];
        for(int j=0;j<61;j++){
            mat[i][j] = t%2;
            t /= 2;
        }
    }

    //cerr << "before" << endl;
    //for(int i=0;i<N;i++){
    //    for(int j=0;j<61;j++) cerr << mat[i][j] << " ";
    //    cerr << endl;
    //}

    vector<bool> use(N,false);
    for(int i=0;i<61;i++){
        int p=-1;
        for(int j=0;j<N;j++){
            if(use[j]) continue;
            if(mat[j][i]==1){
                p=j;
                break;
            }
        }
        cerr << p << endl;
        if(p==-1) continue;
        use[p]=true;
        for(int j=0;j<N;j++){
            if(use[j] or mat[j][i]==0) continue;
            for(int k=0;k<61;k++) mat[j][k] ^= mat[p][k];
        }
    //for(int i=0;i<N;i++){
    //    for(int j=0;j<61;j++) cerr << mat[i][j] << " ";
    //    cerr << endl;
    //}
    }

    //cerr << "after" << endl;
    //for(int i=0;i<N;i++){
    //    for(int j=0;j<61;j++) cerr << mat[i][j] << " ";
    //    cerr << endl;
    //}

    int cnt = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<61;j++) if(mat[i][j]){
            cnt++;
            break;
        }
    }
    ll ans = 1;
    for(int i=0;i<cnt;i++) ans *= 2;
    cout<< ans << endl;
}
0