結果

問題 No.1189 Sum is XOR
ユーザー V_Melville
提出日時 2024-11-07 20:35:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 6,031 ms
コンパイル使用メモリ 317,272 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 20:35:29
合計ジャッジ時間 7,862 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using mint = modint998244353;

struct modfact {
  int n; vector<mint> d;
  modfact(): n(2), d({1,1}) {}
  mint operator()(int i) {
    while (n <= i) d.push_back(d.back()*n), ++n;
    return d[i];
  }
  mint operator[](int i) const { return d[i];}
} facts;

int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    if (k > 10) {
        puts("0");
        return 0;
    }
    
    unordered_map<int, int> cnt;
    rep(i, n) cnt[a[i]]++;
    
    int m = 10, m2 = 1<<m;
    vector dp(m+1, vector<mint>(m2));
    dp[0][0] = 1;
    rep(i, k)rep(s, m2) {
        for (int t = s; t; t = (t-1)&s) {
            dp[i+1][s] += dp[i][s^t]*cnt[t];
        }
    }
    
    mint ans;
    rep(s, m2) ans += dp[k][s];
    ans /= facts(k);
    
    cout << ans.val() << '\n';
    
    return 0;
}
0