結果

問題 No.803 Very Limited Xor Subset
ユーザー koi_kotyakoi_kotya
提出日時 2019-03-20 23:25:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,946 bytes
コンパイル時間 1,706 ms
コンパイル使用メモリ 173,560 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 04:38:09
合計ジャッジ時間 3,450 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,m,x;
    cin >> n >> m >> x;
    vector<vector<int>> b(n,vector<int>(30+m,0));
    vector<int> xs(30+m,0);
    for (int i = 0;i < 30;++i) xs[i] = ((x>>i)&1);
    for (int i = 0;i < n;++i) {
        int a;
        cin >> a;
        for (int j = 0;j < 30;++j) b[i][j] = ((a>>j)&1);
    }
    for (int i = 0;i < m;++i) {
        int t,l,r;
        cin >> t >> l >> r;
        xs[i+30] = t;
        for (int j = l-1;j < r;++j) b[j][i+30] = 1;
    }
    int i = 0;
    for (int j = 0;j < m+30;++j) {
        if (!b[i][j]) for (int k = i;k < n;++k) if (b[k][j]) {
            for (int l = 0;l < m+30;++l) b[i][l] ^= b[k][l];
            break;
        }
        if (b[i][j]) {
            for (int k = 0;k < n;++k) if (k != i && b[k][j]) for (int l = 0;l < m+30;++l) b[k][l] ^= b[i][l];
            ++i;
        }
        if (i == n) break;
    }
    vector<int> c(m+30,0);
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < m+30;++j) if (b[i][j]) {
            if (xs[j]^c[j]) for (int k = 0;k < m+30;++k) c[k] ^= b[i][k];
            break;
        }
    }
    ll ans = 0;
    if (xs == c) {
        int cnt = 0;
        for (int i = 0;i < n;++i) {
            bool ok = true;
            for (int j = 0;j < m+30;++j) if (b[i][j]) {
                ok = false;
                break;
            }
            if (ok) cnt++;
        }
        ans = 1;
        for (int i = 0;i < cnt;++i) {
            ans <<= 1;
            ans %= (int)1e9+7;
        }
    }
    cout << ans << endl;
    return 0;
}
0