結果
問題 | No.803 Very Limited Xor Subset |
ユーザー |
![]() |
提出日時 | 2020-06-10 11:39:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,287 bytes |
コンパイル時間 | 2,966 ms |
コンパイル使用メモリ | 203,224 KB |
最終ジャッジ日時 | 2025-01-11 00:45:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#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;}