結果

問題 No.803 Very Limited Xor Subset
ユーザー nejinejinejineji
提出日時 2021-02-28 20:52:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 3,211 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 173,620 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 10:17:27
合計ジャッジ時間 3,538 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << (t))
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef long double ld;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

//using mint = modint1000000007;
//         mint::set_mod(998244353);

int const BITSET_SIZE = 303;
struct gauss_jordan01{
    vector<bitset<BITSET_SIZE>> equations;
    int num_var;
    bool is_extended;
    gauss_jordan01(int num_varieties, bool extended = false){
        num_var = num_varieties;
        is_extended = extended;
    }
    void add(bitset<BITSET_SIZE> x){
        equations.push_back(x);
        num_equations++;
    }
    int rank = 0;
    bool is_solved = false;
    int num_equations = 0;
    void solve(){
        int n = equations.size();
        int m = num_var;
        for(int i=0; i < m;i++){
            int pivot = -1;
            for(int j=rank; j < n;j++){
                if(equations[j][i]){
                    pivot = j;
                    break;
                }
            }
            if(pivot == -1){
                continue;
            }
            swap(equations[pivot], equations[rank]);
            for(int j=0;j < n;j++){
                if(j != rank && equations[j][i]){
                    equations[j] ^= equations[rank];
                }
            }
            rank++;
        }
        if(is_extended){
            is_solved = true;
            for(int j = rank; j < n;j++){
                if(equations[j][num_var]){
                    is_solved = false;
                }   
            }
        }
    }
    bitset<BITSET_SIZE> solution(){
        bitset<BITSET_SIZE> ans;
        for(int j = 0;j < equations.size();j++){
            if(equations[j][num_var]){
                for(int i=0;i < num_var;i++){
                    ans.set(i, 1);
                }
            }
        }
        return ans;
    }
};

struct query{
    ll tp; ll l; ll r;
};

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    vll a;
    REP(i,0,n-1){
        ll tmp; cin >> tmp;
        a.push_back(tmp);
    }
    vector<query> q;
    REP(i,0,m-1){
        ll t,l,r; cin >> t >> l >> r;
        l--; r--;
        q.push_back({t,l,r});
    }
    gauss_jordan01 gj(n, true);
    REP(i,1,35){
        bitset<BITSET_SIZE> bs;
        REP(j,0,n-1){
            if(a[j] % 2){
                bs.set(j,1);
            }
            a[j] /= 2;
        }
        bs.set(n, x % 2);
        x /= 2;
        gj.add(bs);
    }
    REP(i,0,m-1){
        bitset<BITSET_SIZE> bs;
        query cur = q[i];
        REP(j,cur.l, cur.r){
            bs.set(j,1);
        }
        bs.set(n,cur.tp);
        gj.add(bs);
    }
    gj.solve();
    if(!gj.is_solved){
        cout << 0 << endl;
    }else{
        ll ans = 1;
        ll MOD = 1e9 + 7;
        REP(i,1,n-gj.rank){
            ans *= 2;
            ans %= MOD;
        }
        cout << ans << endl;
    }
}
0