結果

問題 No.803 Very Limited Xor Subset
ユーザー satashunsatashun
提出日時 2019-03-17 22:12:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,754 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 150,708 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 07:02:46
合計ジャッジ時間 4,075 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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[i] >> j) & 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][k] = 1;
		}
		m[i][N] = t;
	}

	int t = get_rank(m);
	if (t > N) {
		puts("0");
	} else {
		ll ans = 1;
		rep(i, N-t) {
			ans = ans * 2 % MOD;
		}
		cout << ans << endl;
	}

	return 0;
}
0