結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー rogi52
提出日時 2022-08-13 12:07:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,198 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 194,920 KB
最終ジャッジ日時 2025-01-30 22:09:38
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 1 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

const int MAX_ROW = 310;
const int MAX_COL = 310;
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]; }
};

int Gauss_Jordan(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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; cin >> N;
    BitMatrix A(N, 15);
    rep(i,N) {
        int a; cin >> a;
        rep(j,15) A[i][j] = a & (1 << j);
    }
    int rank = Gauss_Jordan(A, true);
    cout << (1LL << rank) << endl;
}
0