結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー milanis48663220milanis48663220
提出日時 2020-05-29 21:53:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 859 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 83,032 KB
実行使用メモリ 167,296 KB
最終ジャッジ日時 2024-04-23 21:51:56
合計ジャッジ時間 2,824 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 92 ms
68,864 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 MLE -
testcase_11 AC 52 ms
42,624 KB
testcase_12 AC 40 ms
34,304 KB
testcase_13 AC 53 ms
43,904 KB
testcase_14 AC 56 ms
45,824 KB
testcase_15 AC 145 ms
112,640 KB
testcase_16 AC 27 ms
22,912 KB
testcase_17 AC 29 ms
25,600 KB
testcase_18 AC 140 ms
104,192 KB
testcase_19 AC 51 ms
41,472 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 111 ms
81,920 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;
int N, Q;
ll A[10000], B[10000]; 

ll dp[6005][6005];

void init(){
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= i-1; j++){
            // 1
            dp[i][j+1] += dp[i-1][j];
            dp[i][j+1] %= MOD;
            // 1 以外
            dp[i][j] += dp[i-1][j]*(A[i-1]-1);
            dp[i][j] %= MOD;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> Q;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < Q; i++) cin >> B[i];
    init();
    
    for(int i = 0; i < Q; i++){
        cout << dp[N][B[i]] << endl;
    }
}
0