結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー 👑 nu50218nu50218
提出日時 2019-09-02 21:52:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,497 ms / 5,000 ms
コード長 1,287 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 166,524 KB
実行使用メモリ 9,596 KB
最終ジャッジ日時 2023-09-17 17:52:14
合計ジャッジ時間 27,212 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1,054 ms
7,688 KB
testcase_09 AC 218 ms
4,380 KB
testcase_10 AC 802 ms
6,892 KB
testcase_11 AC 573 ms
5,772 KB
testcase_12 AC 1,231 ms
8,492 KB
testcase_13 AC 1,329 ms
8,940 KB
testcase_14 AC 758 ms
6,488 KB
testcase_15 AC 1,447 ms
9,356 KB
testcase_16 AC 1,198 ms
8,336 KB
testcase_17 AC 1,295 ms
8,740 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 45 ms
9,556 KB
testcase_21 AC 1,497 ms
9,552 KB
testcase_22 AC 1,489 ms
9,564 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 885 ms
7,236 KB
testcase_29 AC 1,230 ms
8,596 KB
testcase_30 AC 1,052 ms
8,016 KB
testcase_31 AC 904 ms
7,416 KB
testcase_32 AC 1,113 ms
8,472 KB
testcase_33 AC 1,447 ms
9,596 KB
testcase_34 AC 1,434 ms
9,256 KB
testcase_35 AC 1,476 ms
9,440 KB
testcase_36 AC 1,472 ms
9,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    bool matrix[N][63];

    for (int i = 0; i < N; i++) {
        long long A;
        cin >> A;
        for (long long j = 0; j < 63; j++) {
            matrix[i][j] = A & ((long long)1 << j);
        }
    }

    for (int i = 0; i < N; i++) {
        int min_bit = 100;
        int min_index = -1;
        for (int j = i; j < N; j++) {
            for (int k = 0; k < 63; k++) {
                if (matrix[j][k]) {
                    if (k < min_bit) {
                        min_index = j;
                        min_bit = k;
                    }
                }
            }
        }
        if (min_index == -1) break;
        for (int k = 0; k < 63; k++) {
            swap(matrix[i][k], matrix[min_index][k]);
        }
        for (int j = i + 1; j < N; j++) {
            if (matrix[j][min_bit]) {
                for (int k = 0; k < 63; k++) {
                    matrix[j][k] ^= matrix[i][k];
                }
            }
        }
    }

    long long ans = 0;

    for (int i = 0; i < N; i++) {
        bool flag = false;
        for (int j = 0; j < 63; j++) {
            flag |= matrix[i][j];
        }
        ans += flag;
    }

    cout << ((long long)1 << ans) << endl;
}
0