結果

問題 No.803 Very Limited Xor Subset
ユーザー betrue12betrue12
提出日時 2019-03-17 23:10:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,673 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 199,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 10:00:17
合計ジャッジ時間 3,684 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 5 ms
4,376 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 5 ms
4,380 KB
testcase_29 AC 5 ms
4,380 KB
testcase_30 AC 5 ms
4,376 KB
testcase_31 AC 5 ms
4,376 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 5 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 4 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 5 ms
4,380 KB
testcase_42 AC 5 ms
4,376 KB
testcase_43 AC 5 ms
4,380 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int64_t MOD = 1e9+7;
int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

void fail(){
    cout << 0 << endl;
    exit(0);
}

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    static int A[300][330];
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        for(int k=0; k<30; k++) A[i][M+k] = nth_bit(a, k);
    }
    int C[330];
    for(int k=0; k<30; k++) C[M+k] = nth_bit(X, k);
    for(int j=0; j<M; j++){
        int t, l, r;
        cin >> t >> l >> r;
        l--; r--;
        C[j] = t;
        for(int i=l; i<=r; i++) A[i][j] = 1;
    }

    int M2 = M+30;
    int rank = 0;
    int row[330];
    for(int j=0; j<M2; j++) row[j] = -1;
    for(int j=0; j<M2; j++){
        int pivot = -1;
        for(int i=rank; i<N; i++){
            if(A[i][j]){
                pivot = i;
                break;
            }
        }
        if(pivot >= 0){
            row[j] = rank;
            if(pivot != rank) for(int k=0; k<M2; k++) swap(A[pivot][k], A[rank][k]);
            for(int i=0; i<N; i++){
                if(i != rank && A[i][j]) for(int k=0; k<M2; k++) A[i][k] ^= A[rank][k];
            }
            rank++;
        }
    }

    int C2[330] = {0};
    for(int j=0; j<M2; j++){
        if(C[j]){
            if(row[j] >= 0) for(int k=0; k<M2; k++) C2[k] ^= A[row[j]][k];
        }
    }
    for(int j=0; j<M2; j++){
        if(C2[j] != C[j]) fail();
    }


    int64_t ans = 1;
    for(int i=0; i<N; i++){
        bool zero = true;
        for(int j=0; j<M2; j++) if(A[i][j]) zero = false;
        if(zero) ans = ans * 2 % MOD;
    }
    cout << ans << endl;
    return 0;
}
0