結果

問題 No.2633 Subsequence Combination Score
ユーザー 👑 potato167potato167
提出日時 2024-02-11 13:33:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,482 bytes
コンパイル時間 2,819 ms
コンパイル使用メモリ 206,384 KB
実行使用メモリ 12,504 KB
最終ジャッジ日時 2024-02-16 20:50:12
合計ジャッジ時間 11,681 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
11,516 KB
testcase_01 AC 15 ms
11,516 KB
testcase_02 AC 15 ms
11,516 KB
testcase_03 AC 87 ms
11,560 KB
testcase_04 AC 36 ms
11,540 KB
testcase_05 AC 39 ms
11,544 KB
testcase_06 AC 87 ms
11,560 KB
testcase_07 AC 41 ms
11,544 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 16 ms
11,516 KB
testcase_30 AC 15 ms
11,516 KB
testcase_31 AC 15 ms
11,516 KB
testcase_32 AC 14 ms
11,516 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
struct mint{
    static constexpr int  m = 998244353;
    int x;
    mint() : x(0){}
    mint(ll x_):x(x_%m){if(x<0)x+=m;}
    mint &operator+=(mint b){if((x+=b.x)>=m)x-=m; return *this;}
    mint &operator-=(mint b){if((x-=b.x)<0)x+=m; return *this;}
    mint &operator*=(mint b){x=ll(x)*b.x%m; return *this;}
    mint pow(ll e) const {
        mint r = 1,b =*this;
        while(e){
            if(e&1) r*=b;
            b*=b;
            e>>=1;
        }
        return r;
    }
    mint inv(){return pow(m-2);}
    mint &operator/=(mint b){return *this*=b.pow(m-2);}
    friend mint operator+(mint a,mint b){return a+=b;}
    friend mint operator-(mint a,mint b){return a-=b;}
    friend mint operator/(mint a,mint b){return a/=b;}
    friend mint operator*(mint a,mint b){return a*=b;}
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
	cin>>N;
	vector<ll> A(N);
	rep(i,0,N) cin>>A[i];
	int L=(1<<20);
	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;
	auto comb=[&](ll a,ll b) -> mint {
		if(a<0||a<b) return 0;
		return fact[a]*fact_inv[b]*fact_inv[a-b];
	};
	assert(N<=6167);
	vector<mint> dp(N);
	mint ans=0;
	rep(i,0,N){
		dp[i]+=1;
		rep(j,0,i) dp[i]+=dp[j]*comb(A[j],A[i]);
		ans+=dp[i];
	}
	cout<<ans.x<<"\n";
}
0