結果

問題 No.2633 Subsequence Combination Score
ユーザー 👑 potato167potato167
提出日時 2024-02-12 01:35:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 1,316 bytes
コンパイル時間 4,347 ms
コンパイル使用メモリ 280,236 KB
実行使用メモリ 9,076 KB
最終ジャッジ日時 2024-02-16 20:51:57
合計ジャッジ時間 13,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 187 ms
9,072 KB
testcase_01 AC 189 ms
9,072 KB
testcase_02 AC 188 ms
9,072 KB
testcase_03 AC 189 ms
9,076 KB
testcase_04 AC 188 ms
9,076 KB
testcase_05 AC 188 ms
9,076 KB
testcase_06 AC 189 ms
9,076 KB
testcase_07 AC 189 ms
9,076 KB
testcase_08 AC 196 ms
9,076 KB
testcase_09 AC 196 ms
9,076 KB
testcase_10 AC 196 ms
9,076 KB
testcase_11 AC 197 ms
9,076 KB
testcase_12 AC 210 ms
9,076 KB
testcase_13 AC 207 ms
9,076 KB
testcase_14 AC 201 ms
9,076 KB
testcase_15 AC 201 ms
9,076 KB
testcase_16 AC 197 ms
9,076 KB
testcase_17 AC 197 ms
9,076 KB
testcase_18 AC 195 ms
9,076 KB
testcase_19 AC 195 ms
9,076 KB
testcase_20 AC 196 ms
9,076 KB
testcase_21 AC 195 ms
9,076 KB
testcase_22 AC 196 ms
9,076 KB
testcase_23 AC 194 ms
9,076 KB
testcase_24 AC 196 ms
9,076 KB
testcase_25 AC 197 ms
9,076 KB
testcase_26 AC 198 ms
9,076 KB
testcase_27 AC 195 ms
9,076 KB
testcase_28 AC 204 ms
9,076 KB
testcase_29 AC 195 ms
9,072 KB
testcase_30 AC 188 ms
9,072 KB
testcase_31 AC 207 ms
9,072 KB
testcase_32 AC 188 ms
9,072 KB
testcase_33 AC 195 ms
9,076 KB
testcase_34 AC 197 ms
9,076 KB
testcase_35 AC 197 ms
9,076 KB
testcase_36 AC 196 ms
9,076 KB
testcase_37 AC 195 ms
9,076 KB
testcase_38 AC 194 ms
9,076 KB
testcase_39 AC 197 ms
9,076 KB
testcase_40 AC 197 ms
9,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
const int mod=998244353;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#include<atcoder/all>
using namespace atcoder;


void solve();
// oddloop
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    //cin>>t;
    rep(i,0,t) solve();
}

void solve(){
    using mint=modint998244353;
    int L=(1<<17);
    int N;
    cin>>N;
    vector<int> A(L);
    rep(i,0,N){
        int a;
        cin>>a;
        A[a]++;
    }
    vector<mint> dp(L);
    vector<mint> fact(L,1),fact_inv(L,1);
    rep(i,1,L) fact[i]=fact[i-1]*i;
    fact_inv[L-1]=fact[L-1].inv();
    for(int i=L-1;i>0;i--) fact_inv[i-1]=fact_inv[i]*i;
    mint ans=0;
    auto f=[&](auto self,int l,int r) -> void {
        if(l+1==r){
            dp[l]+=fact_inv[l];
            dp[l]*=(mint(2).pow(A[l])-1);
            ans+=dp[l]*fact[l];
            return;
        }
        int m=(l+r)/2;
        self(self,l,m);
        vector<mint> p(m-l),q(r-l);
        rep(i,l,m) p[i-l]=dp[i];
        rep(i,0,r-l) q[i]=fact_inv[i];
        p=convolution(p,q);
        rep(i,m,r) dp[i]+=p[i-l];
        self(self,m,r);
    };
    f(f,0,L);
    cout<<ans.val()<<"\n";
}
0