結果
問題 | No.803 Very Limited Xor Subset |
ユーザー |
![]() |
提出日時 | 2019-03-18 17:37:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,922 bytes |
コンパイル時間 | 1,777 ms |
コンパイル使用メモリ | 166,144 KB |
実行使用メモリ | 5,504 KB |
最終ジャッジ日時 | 2024-07-18 12:16:37 |
合計ジャッジ時間 | 2,860 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<ll, ll> P;#define fi first#define se second#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)#define rep(i,n) repl(i,0,n)#define all(x) (x).begin(),(x).end()#define dbg(x) cout<<#x"="<<x<<endl#define mmax(x,y) (x>y?x:y)#define mmin(x,y) (x<y?x:y)#define maxch(x,y) x=mmax(x,y)#define minch(x,y) x=mmin(x,y)#define uni(x) x.erase(unique(all(x)),x.end())#define exist(x,y) (find(all(x),y)!=x.end())#define bcnt __builtin_popcountll#define INF 1e16#define mod 1000000007typedef vector<ll> vec;typedef vector<vec> mat;ll linear_equation(mat A, vec b) { // F_2ll rank = 0;ll n=A.size(),m=A[0].size();for (ll i = 0; i < n; ++i) { A[i].push_back(b[i]); }for (ll i = 0; i < m; ++i) {ll pivot = -1;for (ll j = rank; j < n; ++j) {if (A[j][i]) {pivot = j;break;}}if (pivot != -1) {swap(A[pivot], A[rank]);for (ll j = 0; j < n; ++j) {if (j != rank && A[j][i]) {for(ll k = 0; k <= m; k++){A[j][k] ^= A[rank][k];}}}++rank;}}for (ll i = rank; i < n; ++i) if (A[i][m]) return -1;return rank;}ll mod_pow(ll a,ll n){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}int main(){cin.tie(0);ios::sync_with_stdio(false);ll N,M,X;cin>>N>>M>>X;const ll B=30;vector<vector<ll> > A(B+M,vector<ll>(N,0));vector<ll> b(B+M,0);rep(i,B)if((X>>i)&1)b[i]=1;rep(i,N){ll t;cin>>t;rep(j,B){if((t>>j)&1)A[j][i]=1;}}rep(i,M){ll t,l,r;cin>>t>>l>>r;l--;repl(j,l,r)A[B+i][j]=1;b[B+i]=t;}ll rank=linear_equation(A,b);if(rank==-1){cout<<0<<endl;return 0;}cout<<mod_pow(2,N-rank)<<endl;return 0;}