結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー parukiparuki
提出日時 2016-08-31 15:41:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 5,000 ms
コード長 1,426 bytes
コンパイル時間 1,727 ms
コンパイル使用メモリ 170,648 KB
実行使用メモリ 57,836 KB
最終ジャッジ日時 2023-09-17 17:35:21
合計ジャッジ時間 8,824 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 200 ms
41,888 KB
testcase_09 AC 36 ms
11,036 KB
testcase_10 AC 141 ms
32,904 KB
testcase_11 AC 99 ms
24,276 KB
testcase_12 AC 245 ms
48,216 KB
testcase_13 AC 279 ms
51,980 KB
testcase_14 AC 134 ms
31,092 KB
testcase_15 AC 297 ms
55,856 KB
testcase_16 AC 243 ms
47,248 KB
testcase_17 AC 274 ms
50,608 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 128 ms
57,688 KB
testcase_21 AC 317 ms
57,724 KB
testcase_22 AC 318 ms
57,836 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 174 ms
36,244 KB
testcase_29 AC 263 ms
49,816 KB
testcase_30 AC 211 ms
44,300 KB
testcase_31 AC 178 ms
38,732 KB
testcase_32 AC 245 ms
47,376 KB
testcase_33 AC 312 ms
56,112 KB
testcase_34 AC 303 ms
55,668 KB
testcase_35 AC 309 ms
57,140 KB
testcase_36 AC 307 ms
57,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int rankMat(vector<vector<int> > A){
    int n = (int)A.size(), m = (int)A[0].size();

    for(int i = 0; i < min(n, m); ++i){
        for(int j = i; j < n; ++j){
            if(A[j][i]){
                swap(A[i], A[j]);
                break;
            }
        }
        if(A[i][i] == 0){
            continue;
        }
        for(int j = 0; j < n; ++j){
            if(i!=j && A[j][i]){
                for(int k = i; k < m; ++k){
                    A[j][k] ^= A[i][k];
                }
            }
        }
    }

    int r = n;
    for(int i = 0; i < n; ++i)
        if(accumulate(all(A[i]), 0) == 0)--r;
    return r;
}

int main(){
    const int M = 61;
    int N;
    cin >> N;
    vector<vi> A(N, vi(M));
    rep(i, N){
        ll a; scanf("%lld", &a);
        rep(j, M)if(a >> j & 1)A[i][j] = 1;
    }
    int r = rankMat(A);
    assert(r <= M);
    ll ans = 1ll << r;
    cout << ans << endl;
}
0