結果

問題 No.1189 Sum is XOR
ユーザー ateate
提出日時 2020-08-22 15:12:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 4,303 bytes
コンパイル時間 2,006 ms
コンパイル使用メモリ 204,100 KB
実行使用メモリ 19,392 KB
最終ジャッジ日時 2024-04-23 09:34:57
合計ジャッジ時間 8,546 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<int64_t MOD>
struct mod_int{
  int64_t val;
  constexpr mod_int():val(0){}
  constexpr mod_int(int64_t x)noexcept:val(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD){}
  constexpr int64_t value()const noexcept{return val;}
  constexpr int64_t get_MOD()const noexcept{return MOD;}
  constexpr mod_int operator+(mod_int const& rhs){
    return mod_int(*this)+=rhs;
  }
  constexpr mod_int operator-(mod_int const& rhs){
    return mod_int(*this)-=rhs;
  }
  constexpr mod_int operator*(mod_int const& rhs){
    return mod_int(*this)*=rhs;
  }
  constexpr mod_int operator/(mod_int const& rhs){
    return mod_int(*this)/=rhs;
  }
  constexpr mod_int &operator+=(mod_int const& rhs)noexcept{
    val += rhs.val;
    if(val>=MOD)val-=MOD;
    return *this;
  }
  constexpr mod_int &operator-=(mod_int const& rhs)noexcept{
    if(val<rhs.val)val+=MOD;
    val-=rhs.val;
    return *this;
  }
  constexpr mod_int &operator*=(mod_int const& rhs)noexcept{
    (val*=rhs.val)%=MOD;
    return *this;
  }
  constexpr mod_int &operator/=(mod_int rhs)noexcept{
    *this*=rhs.inverse();
    return *this;
  }
  constexpr bool operator==(mod_int const& rhs)const{
    return val==rhs.val;
  }
  constexpr bool operator!=(mod_int const& rhs)const{
    return !(val==rhs.val);
  }
  constexpr bool operator<(mod_int const& rhs)const{
    return val<rhs.val;
  }
  constexpr bool operator>(mod_int const& rhs)const{
    return val>rhs.val;
  }
  constexpr bool operator<=(mod_int const& rhs)const{
    return !(val>rhs.val);
  }
  constexpr bool operator>=(mod_int const& rhs)const{
    return !(val<rhs.val);
  }
  constexpr friend std::ostream &operator<<(std::ostream& os, mod_int const& mi){
    return os<<mi.val;
  }
  constexpr friend std::istream &operator>>(std::istream& is, mod_int & mi){
    int64_t t=0;is>>t;
    mi = mod_int<MOD>(t);
    return is;
  }
  constexpr mod_int inverse(){
    int64_t a=val,b=MOD,u=1,v=0,t=0;
    while(b>0){
      t=a/b;
      std::swap(a-=t*b,b);
      std::swap(u-=t*v,v);
    }
    return mod_int(u);
  }
  constexpr mod_int mpow(int64_t n)const{
    mod_int res(1),e(*this);
    while(n){
      if(n&1)res*=e;
      e*=e;
      n>>=1;
    }
    return res;
  }
};
using mint = mod_int<119<<23|1>;
mint mpow(int64_t p,int64_t n){
  mint res=1;
  mint e = p;
  while(n){
    if(n&1)res*=e;
    e*=e;
    n>>=1;
  }
  return res;
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  cin>>a;

  if(k>10){
    cout<<0<<endl;
    return 0;
  }

  //dp[i][j][S] := i番目まで見てj個使ってsum xorがSになる場合の数
  constexpr int S = 10000+10;
  auto dp1 = vec<mint>(10+1,S);
  auto dp2 = vec<mint>(10+1,S);
  dp1[0][0] = 1;
  rep(i,n){
    dp2 = dp1;
    rep(j,k)rep(s,S){
      if((s&a[i])!=0)continue;
      dp2[j+1][s|a[i]] += dp1[j][s];
    }
    dp1 = dp2;
  }
  mint ans = 0;
  rep(s,S)ans+=dp1[k][s];
  cout<<(ans)<<endl;
/*
  rep(i,n+1){
    rep(j,k+1){
      rep(s,10)cout<<dp[i][j][s]<<" ";
      cout<<endl;
    }
    cout<<endl;
  }
*/

}
0