結果

問題 No.803 Very Limited Xor Subset
ユーザー m_tsubasam_tsubasa
提出日時 2020-06-10 11:39:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,287 bytes
コンパイル時間 2,840 ms
コンパイル使用メモリ 207,912 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 02:30:46
合計ジャッジ時間 5,935 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD (long long)(1e9 + 7)
using namespace std;

using bs = bitset<400>;

long long n, m;
bs x;
vector<bs> a, basis;

long long solve();

int main() {
  cin >> n >> m;
  {
    long long p;
    cin >> p;
    for (int i = 0; i < 31; ++i)
      if (p >> i & 1) x[m + i] = 1;
  }
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    long long p;
    cin >> p;
    for (int j = 0; j < 31; ++j)
      if (p >> j & 1) a[i][m + j] = 1;
  }
  for (int i = 0; i < m; ++i) {
    int t, l, r;
    cin >> t >> l >> r;
    x[i] = t;
    for (int j = l - 1; j < r; ++j) a[j][i] = 1;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  int cnt = 0;
  auto ask = [](bs l, bs r) {
    for (int i = 0; i < m + 31; ++i)
      if (l[i] ^ r[i]) return (bool)l[i];
    return false;
  };
  for (int i = 0; i < n; ++i) {
    for (auto b : basis)
      if (ask(a[i], a[i] ^ b)) a[i] ^= b;
    if (a[i].any())
      basis.push_back(a[i]);
    else
      ++cnt;
  }
  sort(basis.begin(), basis.end(), ask);
  for (auto b : basis) {
    int id = 0;
    while (!b[id]) ++id;
    if (x[id]) x ^= b;
  }
  if (x.any()) return 0;
  long long res = 1, two = 2;
  while (cnt) {
    if (cnt & 1) (res *= two) %= MOD;
    cnt >>= 1;
    (two *= two) %= MOD;
  }
  return res;
}
0