結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー oteraotera
提出日時 2020-06-09 03:10:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 2,922 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 111,612 KB
実行使用メモリ 4,732 KB
最終ジャッジ日時 2023-09-17 18:15:42
合計ジャッジ時間 4,329 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,556 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 44 ms
4,416 KB
testcase_09 AC 13 ms
4,380 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 26 ms
4,588 KB
testcase_12 AC 51 ms
4,556 KB
testcase_13 AC 55 ms
4,668 KB
testcase_14 AC 33 ms
4,500 KB
testcase_15 AC 58 ms
4,680 KB
testcase_16 AC 50 ms
4,632 KB
testcase_17 AC 53 ms
4,680 KB
testcase_18 AC 2 ms
4,400 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 16 ms
4,732 KB
testcase_21 AC 61 ms
4,680 KB
testcase_22 AC 60 ms
4,556 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 3 ms
4,388 KB
testcase_27 AC 3 ms
4,520 KB
testcase_28 AC 38 ms
4,416 KB
testcase_29 AC 52 ms
4,628 KB
testcase_30 AC 45 ms
4,548 KB
testcase_31 AC 39 ms
4,380 KB
testcase_32 AC 48 ms
4,704 KB
testcase_33 AC 59 ms
4,548 KB
testcase_34 AC 59 ms
4,564 KB
testcase_35 AC 61 ms
4,672 KB
testcase_36 AC 60 ms
4,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int MAX_ROW = 65; // to be set appropriately
const int MAX_COL = 110000; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

ostream& operator << (ostream& s, BitMatrix A) {
    s << endl; 
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << endl;
    }
    return s;
}

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    const int DIGIT = 61;
    BitMatrix A(DIGIT, n);
    rep(d, DIGIT) {
        rep(i, n) {
            if(a[i] & (1LL<<d)) A[d][i] = 1;
        }
    }
    int rank = GaussJordan(A);
    cout << (1LL<<rank) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}
0