結果

問題 No.803 Very Limited Xor Subset
ユーザー satashunsatashun
提出日時 2019-03-17 22:24:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,893 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 150,112 KB
実行使用メモリ 4,412 KB
最終ジャッジ日時 2023-09-22 07:44:24
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 1000000007;
typedef vector<vi> mat;

int get_rank(mat &A) //mod 2
{
	const int n = A.size(), m = A[0].size();
	int r = 0;
	for (int i = 0; r < n && i < m; ++i) {
		int pivot = r;
		for (int j = r+1; j < n; ++j) {
			if (A[j][i]) {
				pivot = j;
				break;
			}
		}
		swap(A[pivot], A[r]);
		if (A[r][i] == 0) continue;
		for (int j = r+1; j < n; ++j) {
			if (A[j][i]) {
				for (int k = i; k < m; ++k) {
					A[j][k] ^= A[r][k];
				}       
			}
		}
		++r;
	}
	return r;
}

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	mat m(M + 30, vi(N + 1, 0));
	vi a(N);
	rep(i, N) cin >> a[i];

	for (int i = 0; i < 30; ++i) {
		rep(j, N) {
			m[i][j] = (a[j] >> i) & 1;
		}
		m[i][N] = (X >> i) & 1;
	}		

	rep(i, M) {
		int t, l, r;
		cin >> t >> l >> r;
		--l; --r;
		for (int k = l; k <= r; ++k) {
			m[i+30][k] = 1;
		}
		m[i+30][N] = t;
	}

	mat m2(M + 30, vi(N));
	rep(i, m2.size()) {
		rep(j, m2[i].size()) {
			m2[i][j] = m[i][j];
		}
	}
	int r = get_rank(m2);
	get_rank(m);
	
	if (r > N || m[r][N] != 0) {
		puts("0");
	} else {
		ll ans = 1;
		rep(i, N-r) {
			ans = ans * 2 % MOD;
		}
		cout << ans << endl;
	}

	return 0;
}
0