結果

問題 No.803 Very Limited Xor Subset
ユーザー erbowlerbowl
提出日時 2020-06-12 09:57:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 1,670 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 211,684 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 08:57:35
合計ジャッジ時間 6,871 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll n,m,x;
    std::cin >> n>>m>>x;
    vector<bitset<400>> rows(n);
    vector<bitset<400>> bases;
    bases.push_back(bitset<400>(0));
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        rows[i] = bitset<400>(a[i]);
    }
    vector<ll> t(m);
    auto xx = bitset<400>(x);
    for (int i = 0; i < m; i++) {
        ll tt,l,r;
        std::cin >> tt>>l>>r;
        t[i] = tt;
        if(tt==1)xx.set(40+i);
        for (int j = l-1; j < r; j++) {
            rows[j].set(40+i);
        }
    }

    sort(rows.rbegin(),rows.rend(), [](const auto & lhs, const auto & rhs)
                                    { return lhs.to_string() < rhs.to_string(); });
                                    
    ll zeroc = 0;
    for (int i = 0; i < n; i++) {
        bitset<400> v = rows[i];
        for (auto e : bases) {
            auto tmp = v ^ e;
            if(tmp.to_string()<v.to_string())v = tmp;
        }
        if(v!=bitset<400>(0)){
            bases.push_back(v);
        }
        rows[i] = v;
        if(v==bitset<400>(0))zeroc++;
    }
    
    
    for (auto e : bases) {
        auto tmp = xx ^ e;
        if(tmp.to_string()<xx.to_string())xx = tmp;
    }
    
    if(xx!=bitset<400>(0)){
        std::cout << 0 << std::endl;
        return 0;
    }
    
    std::cout << modpow(2,zeroc,1e9+7) << std::endl;
}
0