結果

問題 No.803 Very Limited Xor Subset
ユーザー DAyamaCTFDAyamaCTF
提出日時 2019-03-18 17:37:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,922 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 152,112 KB
実行使用メモリ 5,572 KB
最終ジャッジ日時 2023-09-25 15:32:26
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 6 ms
4,776 KB
testcase_15 AC 6 ms
4,984 KB
testcase_16 AC 6 ms
4,908 KB
testcase_17 AC 6 ms
4,928 KB
testcase_18 AC 6 ms
5,092 KB
testcase_19 AC 6 ms
5,040 KB
testcase_20 AC 6 ms
5,076 KB
testcase_21 AC 6 ms
5,192 KB
testcase_22 AC 6 ms
5,092 KB
testcase_23 AC 7 ms
5,456 KB
testcase_24 AC 7 ms
5,468 KB
testcase_25 AC 7 ms
5,376 KB
testcase_26 AC 7 ms
5,360 KB
testcase_27 AC 7 ms
5,356 KB
testcase_28 AC 7 ms
5,364 KB
testcase_29 AC 7 ms
5,476 KB
testcase_30 AC 6 ms
5,276 KB
testcase_31 AC 8 ms
5,560 KB
testcase_32 AC 7 ms
5,572 KB
testcase_33 AC 7 ms
5,388 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 4 ms
5,420 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,508 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 5 ms
5,484 KB
testcase_41 AC 5 ms
5,452 KB
testcase_42 AC 5 ms
5,280 KB
testcase_43 AC 5 ms
5,360 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 1000000007

typedef vector<ll> vec;
typedef vector<vec> mat;
ll linear_equation(mat A, vec b) { // F_2
  ll 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;
}
0