結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー simkarensimkaren
提出日時 2020-05-30 15:20:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 180,756 KB
実行使用メモリ 284,928 KB
最終ジャッジ日時 2024-04-25 07:32:05
合計ジャッジ時間 5,029 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 124 ms
105,216 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 MLE -
testcase_11 AC 70 ms
60,288 KB
testcase_12 AC 54 ms
46,080 KB
testcase_13 AC 71 ms
62,336 KB
testcase_14 AC 76 ms
65,408 KB
testcase_15 MLE -
testcase_16 AC 31 ms
27,648 KB
testcase_17 AC 37 ms
32,256 KB
testcase_18 MLE -
testcase_19 AC 66 ms
57,984 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 MLE -
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

constexpr ll mod = 998244353LL;

int main(void){
    int N, Q; cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    vector<vector<ll>> DP(N + 1, vector<ll>(N + 1, 0LL));
    DP[0][0] = 1LL;
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < N; ++j){
            DP[i + 1][j] = (DP[i + 1][j] + DP[i][j] * (A[i] - 1) % mod) % mod;
            DP[i + 1][j + 1] = (DP[i + 1][j + 1] + DP[i][j]) % mod;
        }
    }
    while (Q--){
        int B; cin >> B;
        cout << DP[N][B] << endl;
    }
    return 0;
}
0