結果
| 問題 |
No.803 Very Limited Xor Subset
|
| コンテスト | |
| ユーザー |
nejineji
|
| 提出日時 | 2021-02-28 20:52:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 3,211 bytes |
| コンパイル時間 | 1,761 ms |
| コンパイル使用メモリ | 178,284 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 21:57:17 |
| 合計ジャッジ時間 | 3,352 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << (t))
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef long double ld;
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
//using mint = modint1000000007;
// mint::set_mod(998244353);
int const BITSET_SIZE = 303;
struct gauss_jordan01{
vector<bitset<BITSET_SIZE>> equations;
int num_var;
bool is_extended;
gauss_jordan01(int num_varieties, bool extended = false){
num_var = num_varieties;
is_extended = extended;
}
void add(bitset<BITSET_SIZE> x){
equations.push_back(x);
num_equations++;
}
int rank = 0;
bool is_solved = false;
int num_equations = 0;
void solve(){
int n = equations.size();
int m = num_var;
for(int i=0; i < m;i++){
int pivot = -1;
for(int j=rank; j < n;j++){
if(equations[j][i]){
pivot = j;
break;
}
}
if(pivot == -1){
continue;
}
swap(equations[pivot], equations[rank]);
for(int j=0;j < n;j++){
if(j != rank && equations[j][i]){
equations[j] ^= equations[rank];
}
}
rank++;
}
if(is_extended){
is_solved = true;
for(int j = rank; j < n;j++){
if(equations[j][num_var]){
is_solved = false;
}
}
}
}
bitset<BITSET_SIZE> solution(){
bitset<BITSET_SIZE> ans;
for(int j = 0;j < equations.size();j++){
if(equations[j][num_var]){
for(int i=0;i < num_var;i++){
ans.set(i, 1);
}
}
}
return ans;
}
};
struct query{
ll tp; ll l; ll r;
};
int main(){
ll n,m,x;
cin >> n >> m >> x;
vll a;
REP(i,0,n-1){
ll tmp; cin >> tmp;
a.push_back(tmp);
}
vector<query> q;
REP(i,0,m-1){
ll t,l,r; cin >> t >> l >> r;
l--; r--;
q.push_back({t,l,r});
}
gauss_jordan01 gj(n, true);
REP(i,1,35){
bitset<BITSET_SIZE> bs;
REP(j,0,n-1){
if(a[j] % 2){
bs.set(j,1);
}
a[j] /= 2;
}
bs.set(n, x % 2);
x /= 2;
gj.add(bs);
}
REP(i,0,m-1){
bitset<BITSET_SIZE> bs;
query cur = q[i];
REP(j,cur.l, cur.r){
bs.set(j,1);
}
bs.set(n,cur.tp);
gj.add(bs);
}
gj.solve();
if(!gj.is_solved){
cout << 0 << endl;
}else{
ll ans = 1;
ll MOD = 1e9 + 7;
REP(i,1,n-gj.rank){
ans *= 2;
ans %= MOD;
}
cout << ans << endl;
}
}
nejineji