結果

問題 No.803 Very Limited Xor Subset
ユーザー pekempeypekempey
提出日時 2019-03-17 22:43:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,778 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 78,964 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 08:45:37
合計ジャッジ時間 2,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

const int MOD = 1e9 + 7;
 
struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};
 
mint operator-(mint a) { return a.n == 0 ? 0 : MOD - a.n; }
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(N);
  // 0bit A[i]x = X
  REP(i, N) cin >> A[i];
  vector<bitset<301>> mat;
  REP(i, 30) {
    bitset<301> x;
    REP(j, N) {
      x[j] = A[j] >> i & 1;
    }
    x[300] = X >> i & 1;
    mat.push_back(x);
  }
  REP(i, M) {
    int t, l, r;
    cin >> t >> l >> r;
    l--;
    bitset<301> x;
    for (int i = l; i < r; i++) {
      x[i] = 1;
    }
    x[300] = t;
    mat.push_back(x);
  }
  int r = 0;
  for (int j = 0; j <= 300 && r < mat.size(); j++) {
    int k = -1;
    for (int i = r; i < mat.size(); i++) {
      if (mat[i][j]) {
        k = i;
        break;
      }
    }
    if (k == -1) continue;
    swap(mat[k], mat[r]);
    for (int i = r + 1; i < mat.size(); i++) {
      if (mat[i][j]) {
        mat[i] ^= mat[r];
      }
    }
    r++;
  }
  // dim(ker(mat)) + rank(mat) = N
  REP(i, mat.size()) {
    int z = 1;
    REP(j, N) {
      z &= !mat[i][j];
    }
    if (z && mat[i][300]) {
      cout << 0 << endl;
      return 0;
    }
  }
  mint ans = 1;
  REP(i, N - r) ans *= 2;
  cout << ans.n << endl;
}
0