結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー rogi52rogi52
提出日時 2022-08-13 12:07:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,198 bytes
コンパイル時間 2,704 ms
コンパイル使用メモリ 202,748 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 21:03:59
合計ジャッジ時間 4,964 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 2 ms
4,348 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

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