結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー yuji9511yuji9511
提出日時 2020-05-29 22:27:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 1,332 ms
コンパイル使用メモリ 162,588 KB
実行使用メモリ 96,000 KB
最終ジャッジ日時 2024-04-23 23:24:47
合計ジャッジ時間 2,880 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 123 ms
96,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int dp[6010][6010] = {};
void solve(){
    ll N,Q;
    cin >> N >> Q;
    int A[200010];
    int B[200010];
    rep(i,0,N) cin >> A[i];
    rep(i,0,Q) cin >> B[i];
    dp[0][1] = A[0]-1;
    rep(i,1,N){
        dp[i][1] = dp[i-1][1] + A[i]-1;
        dp[i][1] %= MOD;
    }
    rep(i,0,N){
        rep(j,2,N+1){
            if(j > i+1) continue;
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-1] * (A[i]-1) % MOD) % MOD;
        }
    }
    dp[N-1][0] = 1;
    rep(i,0,Q){
        print(dp[N-1][N - B[i]]);
    }

    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0