結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー SSRSSSRS
提出日時 2020-11-06 20:50:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 581 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 171,420 KB
実行使用メモリ 284,864 KB
最終ジャッジ日時 2023-09-29 17:58:17
合計ジャッジ時間 5,490 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 102 ms
104,868 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 MLE -
testcase_11 AC 60 ms
60,004 KB
testcase_12 AC 45 ms
45,864 KB
testcase_13 AC 60 ms
62,032 KB
testcase_14 AC 65 ms
65,072 KB
testcase_15 MLE -
testcase_16 AC 28 ms
27,584 KB
testcase_17 AC 32 ms
31,820 KB
testcase_18 MLE -
testcase_19 AC 57 ms
57,628 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 131 ms
127,900 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<long long>> dp(N + 1, vector<long long>(N + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < N; i++){
    for (int j = 0; j <= i; j++){
      dp[i + 1][j] += dp[i][j] * (A[i] - 1);
      dp[i + 1][j] %= MOD;
      dp[i + 1][j + 1] += dp[i][j];
      dp[i + 1][j + 1] %= MOD;
    }
  }
  for (int i = 0; i < Q; i++){
    int B;
    cin >> B;
    cout << dp[N][B] << endl;
  }
}
0