結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー kappybarkappybar
提出日時 2020-05-29 21:50:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 767 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 169,380 KB
実行使用メモリ 285,184 KB
最終ジャッジ日時 2024-04-23 21:26:56
合計ジャッジ時間 4,649 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 123 ms
105,088 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 MLE -
testcase_11 AC 68 ms
60,288 KB
testcase_12 AC 53 ms
46,080 KB
testcase_13 AC 70 ms
62,208 KB
testcase_14 AC 76 ms
65,536 KB
testcase_15 MLE -
testcase_16 AC 31 ms
27,776 KB
testcase_17 AC 36 ms
32,384 KB
testcase_18 MLE -
testcase_19 AC 67 ms
58,240 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 MLE -
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
using vc = pair<ll,vector<ll>>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 998244353;

int main(){
    int n,q;
    cin >> n >> q;
    vector<ll> a(n),b(q);
    rep(i,n) cin >> a[i];
    rep(i,q) cin >> b[i];
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        rep(j,n+1){
            if(j > 0) dp[i][j] = ((dp[i-1][j]*(a[i-1]-1))%MOD + dp[i-1][j-1])%MOD;
            else dp[i][j] = (dp[i-1][j]*(a[i-1]-1))%MOD;
        }
    }
    rep(i,q){
        cout << dp[n][b[i]] << '\n' ;
    }
    return 0;
}
0