結果

問題 No.1189 Sum is XOR
ユーザー yukudoyukudo
提出日時 2020-08-31 04:06:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 2,187 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 170,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 13:58:49
合計ジャッジ時間 2,499 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
6,816 KB
testcase_01 AC 22 ms
6,944 KB
testcase_02 AC 21 ms
6,944 KB
testcase_03 AC 10 ms
6,940 KB
testcase_04 AC 9 ms
6,940 KB
testcase_05 AC 14 ms
6,940 KB
testcase_06 AC 20 ms
6,944 KB
testcase_07 AC 12 ms
6,940 KB
testcase_08 AC 5 ms
6,944 KB
testcase_09 AC 6 ms
6,940 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 7 ms
6,944 KB
testcase_12 AC 21 ms
6,940 KB
testcase_13 AC 19 ms
6,944 KB
testcase_14 AC 13 ms
6,944 KB
testcase_15 AC 7 ms
6,944 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 7 ms
6,940 KB
testcase_18 AC 9 ms
6,944 KB
testcase_19 AC 16 ms
6,940 KB
testcase_20 AC 17 ms
6,940 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {if ((x += a.x) >= MOD) x -= MOD;return *this;}
  mint& operator-=(const mint a) {if ((x += MOD-a.x) >= MOD) x -= MOD;return *this;}
  mint& operator*=(const mint a) {(x *= a.x) %= MOD;return *this;}
  mint operator+(const mint a) const {mint res(*this);return res+=a;}
  mint operator-(const mint a) const {mint res(*this);return res-=a;}
  mint operator*(const mint a) const {mint res(*this);return res*=a;}
  mint pow(ll b) const {
    mint res(1), a(*this);
    while (b) {
      if (b & 1) res *= a;
      a *= a;
      b >>= 1;
    }
    return res;
  }
  // for prime MOD
  mint inv() const {return pow(MOD-2);}
  mint& operator/=(const mint a) {return (*this) *= a.inv();}
  mint operator/(const mint a) const {mint res(*this);return res/=a;}
};
ostream& operator<<(ostream& os, const mint& a) {os << a.x; return os;}


mint dp[11][1024];

int main2() {

  REP(i, 11) REP(j, 1024) dp[i][j] = 0;

  int N = nextLong();
  int K = nextLong();
  vector<int> A(N); REP(i, N) A[i] = nextLong();

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

  vector<ll> C(1024);
  REP(i, N) C[A[i]]++;

  dp[0][0] = 1;
  for (int a = 0; a < 1024; a++) {
    REP(s, 1024) {
      if ((s | a) == (s ^ a)) {
        for (int k = 0; k < K; k++) {
          dp[k+1][ s | a ] += dp[k][s] * mint(C[a]);
        }
      }
    }
  }
  mint ans = 0;
  REP(s, 1024) ans += dp[K][s];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}
0