結果

問題 No.2633 Subsequence Combination Score
ユーザー noya2noya2
提出日時 2024-02-12 01:14:07
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,758 bytes
コンパイル時間 4,688 ms
コンパイル使用メモリ 315,336 KB
実行使用メモリ 14,272 KB
最終ジャッジ日時 2024-02-16 20:51:28
合計ジャッジ時間 11,985 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
14,272 KB
testcase_01 AC 128 ms
14,272 KB
testcase_02 AC 127 ms
14,272 KB
testcase_03 AC 129 ms
14,272 KB
testcase_04 AC 131 ms
14,272 KB
testcase_05 AC 129 ms
14,272 KB
testcase_06 AC 128 ms
14,272 KB
testcase_07 AC 128 ms
14,272 KB
testcase_08 AC 138 ms
14,272 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 144 ms
14,272 KB
testcase_12 WA -
testcase_13 AC 142 ms
14,272 KB
testcase_14 WA -
testcase_15 AC 141 ms
14,272 KB
testcase_16 WA -
testcase_17 AC 142 ms
14,272 KB
testcase_18 WA -
testcase_19 AC 137 ms
14,272 KB
testcase_20 AC 136 ms
14,272 KB
testcase_21 AC 136 ms
14,272 KB
testcase_22 AC 135 ms
14,272 KB
testcase_23 AC 140 ms
14,272 KB
testcase_24 AC 135 ms
14,272 KB
testcase_25 AC 134 ms
14,272 KB
testcase_26 AC 135 ms
14,272 KB
testcase_27 AC 136 ms
14,272 KB
testcase_28 AC 135 ms
14,272 KB
testcase_29 WA -
testcase_30 AC 128 ms
14,272 KB
testcase_31 AC 129 ms
14,272 KB
testcase_32 AC 127 ms
14,272 KB
testcase_33 AC 153 ms
14,272 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

const int bx = 19;
const int mx = 1<<bx;
int cnt[mx];
mint dp[mx], fact[mx], ifact[mx];

void factrial_build(){
    fact[0] = 1;
    for (int i = 1; i < mx; i++){
        fact[i] = fact[i-1] * i;
    }
    ifact[mx-1] = fact[mx-1].inv();
    for (int i = mx-2; i >= 0; i--){
        ifact[i] = ifact[i+1] * (i+1);
    }
}

array<vector<mint>,bx> fs, ex;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    while (n--){
        int x; cin >> x;
        cnt[x]++;
    }
    factrial_build();
    for (int d = 1; d < bx; d++){
        fs[d].resize(1<<d);
        ex[d].resize(1<<d);
        for (int i = 0; i < (1<<(d-1)); i++){
            ex[d][i] = ifact[i];
        }
        atcoder::internal::butterfly(ex[d]);
    }
    dp[0] = 1;
    auto dfs = [&](auto sfs, int l, int r, int k) -> void {
        if (r - l <= 1) return ;
        int m = (l + r) / 2;
        sfs(sfs,l,m,k-1);
        fill(fs[k+1].begin(),fs[k+1].end(),0);
        for (int i = l; i < m; i++){
            fs[k+1][i-l] = dp[i];
        }
        atcoder::internal::butterfly(fs[k+1]);
        for (int i = 0; i < (1<<(k+1)); i++){
            fs[k+1][i] *= ex[k+1][i];
        }
        atcoder::internal::butterfly_inv(fs[k+1]);
        mint iv = ifact[1<<(k+1)] * fact[(1<<(k+1))-1];
        for (auto &x : fs[k+1]) x *= iv;
        for (int i = (1<<(k-1)); i < (1<<k); i++){
            dp[l+i] += fs[k+1][i] * (mint(2).pow(cnt[l+i])-1);
        }
        sfs(sfs,m,r,k-1);
    };
    dfs(dfs,0,1<<17,17);
    mint ans = -1;
    for (int i = 0; i < mx; i++){
        ans += dp[i] * fact[i];
    }
    cout << ans.val() << endl;
}
0