結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー chakkuchakku
提出日時 2016-03-31 03:45:09
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,768 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 79,936 KB
実行使用メモリ 44,152 KB
最終ジャッジ日時 2023-09-17 17:28:57
合計ジャッジ時間 8,191 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 176 ms
4,376 KB
testcase_03 AC 32 ms
4,380 KB
testcase_04 AC 59 ms
4,376 KB
testcase_05 AC 64 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 91 ms
4,376 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 <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