結果

問題 No.803 Very Limited Xor Subset
ユーザー milanis48663220milanis48663220
提出日時 2019-09-16 20:43:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,158 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 54,312 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-21 08:06:23
合計ジャッジ時間 3,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

char a[400][400];

char x[360];

const long MOD = 1000000007;

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    for(int i = 0; i < 30; i++){
        int m = 1<<i;
        if(m&X) x[i] = 1;
        else x[i] = 0;
    }
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        for(int j = 0; j < 30; j++){
            int m = 1<<j;
            if(m&A) a[j][i] = 1;
            else a[j][i] = 0;
        }
    }
    for(int i = 0; i < M; i++){
        int t, l, r;
        cin >> t >> l >> r;
        for(int j = l-1; j <= r-1; j++){
            a[30+i][j] = 1;
        }
        if(t == 1) x[30+i] = 1;
    }
    /*
    for(int i = 0; i < M+30; i++){
        for(int j = 0; j < N; j++){
            cout << (int) a[i][j];
        }
        cout << ' ' << (int)x[i];
        cout << endl;
    }
    cout << endl;*/
    for(int i = 0; i < 30+M && i < N; i++){
        bool find = false;
        if(a[i][i] == 1) find = true;
        else{
            for(int j = i+1; j < 30+M ; j++){
                if(a[j][i] == 1){
                    find = true;
                    for(int k = 0; k < N; k++) swap(a[i][k], a[j][k]);
                    swap(x[i], x[j]);
                }
            }
        }
        if(find){
            for(int j = 0; j < 30+M; j++){
                if(i != j && a[j][i] == 1){
                    for(int k = 0; k < N; k++){
                        a[j][k] ^= a[i][k];
                    }
                    x[j] ^= x[i];
                }
            }
        }
    }
    /*
    for(int i = 0; i < M+30; i++){
        for(int j = 0; j < N; j++){
            cout << (int) a[i][j];
        }
        cout << ' ' << (int)x[i];
        cout << endl;
    }*/
    long ans = 1;

    for(int i = 0; i < 30+M ; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            if(a[i][j] == 1) cnt++;
        }
        if(cnt == 0 && x[i] == 1){
            cout << 0 << endl;
            return 0;
        }
        if(cnt == 0 && x[i] == 0 && i < min(N, 30+M)){
            ans *= 2;
            ans %= MOD;
        }
    }
    
    cout << ans << endl;
}
0