結果

問題 No.803 Very Limited Xor Subset
ユーザー E31415926E31415926
提出日時 2019-03-20 01:03:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 3,156 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 99,932 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-12 17:34:35
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int MAX_ROW = 610;
const int MAX_COL = 610;

struct BitMatrix {
    int n, m;
    bitset<MAX_COL> val[MAX_ROW];

    BitMatrix(int n = 1, int m = 1) : n(n), m(m) {}

    inline bitset<MAX_COL> &operator[](int i) { return val[i]; }
};

int linear_equation(BitMatrix A, vector<int> b) {
    int rank = 0;
    rep(i, A.n)A[i][A.m] = b[i];

    rep(i, A.m) {
        int pivot = -1;
        for (int j = rank; j < A.n; ++j) {
            if (A[j][i]) {
                pivot = j;
                break;
            }
        }
        if (pivot != -1) {
            swap(A[pivot], A[rank]);
            rep(j, A.n)if (j != rank && A[j][i])A[j] ^= A[rank];
            ++rank;
        }
    }

    for (int i = rank; i < A.n; ++i)if (A[i][A.m])return -1;
    return rank;
}

//const int mod = //998244353;
const int mod = 1000000007;
const int FacN = 0;//使わないなら0

constexpr int power(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)res *= a;
        a *= a;
        res %= mod;
        a %= mod;
        b /= 2;
    }
    return res;
}

constexpr int inv(int x) {
    return power(x, mod - 2);
}

const struct Fac {
    int val[FacN];

    constexpr Fac() : val() {
        if (FacN == 0)return;
        val[0] = 1;
        for (int i = 1; i < FacN; ++i) val[i] = val[i - 1] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac;

const struct FacInv {
    int val[FacN];

    constexpr FacInv() : val() {
        if (FacN == 0)return;
        val[FacN - 1] = 1;
        for (int i = 1; i < FacN; ++i)val[FacN - 1] = val[FacN - 1] * i % mod;
        val[FacN - 1] = inv(val[FacN - 1]);
        for (int i = FacN - 1; i >= 1; --i)val[i - 1] = val[i] * i % mod;
    }

    const int &operator[](size_t i) const {
        return val[i];
    }
} fac_inv;

int Perm(int n, int r) {
    if (n < r) return 0;
    return fac[n] * fac_inv[n - r] % mod;
}

int Comb(int n, int r) {
    return Perm(n, r) * fac_inv[r] % mod;
}
//mod,Factorial書き換え
//要検証

const int DIGIT = 35;

signed main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    BitMatrix A(DIGIT + M, N);
    vector<int> b(DIGIT + M);
    rep(d, DIGIT) {
        rep(i, N) {
            if (a[i] & (1ll << d))A[d][i] = 1;
        }
        if (X & (1ll << d))b[d] = 1;
    }
    for (int d = 0; d < M; ++d) {
        int type, l, r;
        cin >> type >> l >> r;
        --l, --r;
        for (int i = l; i <= r; ++i)A[d + DIGIT][i] = 1;
        b[d + DIGIT] = type;
    }
    int rank = linear_equation(A, b);
    if (rank == -1)cout << 0 << endl;
    else cout << power(2, N - rank) << endl;
    return 0;
}
0