結果

問題 No.803 Very Limited Xor Subset
ユーザー milanis48663220milanis48663220
提出日時 2019-09-16 22:51:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 2,296 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 54,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 08:10:14
合計ジャッジ時間 3,115 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;

char a[400][400];

char x[360];

const long MOD = 1000000007;
bool used[400];

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 < 31; 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[31+i][j] = 1;
        }
        if(t == 1) x[31+i] = 1;
    }
    /*
    for(int i = 0; i < M+31; i++){
        for(int j = 0; j < N; j++){
            cout << (int) a[i][j];
        }
        cout << ' ' << (int)x[i];
        cout << endl;
    }
    cout << endl;*/
    int cur = 0;
    for(int i = 0; i < max(31+M, N); i++){
        bool find = false;
        for(int j = cur; j < 31+M ; j++){
            if(a[j][i] == 1){
                find = true;
                for(int k = 0; k < N; k++) swap(a[cur][k], a[j][k]);
                swap(x[j], x[cur]);
                break;
            }
        }
        //cout << cur << ' ' << i << endl;;
        if(find){
            for(int j = 0; j < 31+M; j++){
                if(cur != j && a[j][i] == 1){
                    for(int k = 0; k < N; k++){
                        a[j][k] ^= a[cur][k];
                    }
                    x[j] ^= x[cur];
                }
            }
            cur++;
        }
    }
    /*
    for(int i = 0; i < M+31; i++){
        for(int j = 0; j < N; j++){
            cout << (int) a[i][j];
        }
        cout << ' ' << (int)x[i];
        cout << endl;
    }
    */
    int c = 0;
    int r = 0;
    for(int i = 0; i < 31+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) r++;
    }
    long ans = 1;
    //cout << r << endl;
    for(int i = 0; i < N-r; i++){
        ans *= 2;
        ans %= MOD;
    }
    //cout << N-r << endl;
    //cout << c << endl;
    cout << ans << endl;
}
0