結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-20 21:10:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,225 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 69,312 KB
実行使用メモリ 320,288 KB
最終ジャッジ日時 2023-09-16 17:48:21
合計ジャッジ時間 10,551 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,472 KB
testcase_01 AC 2 ms
5,408 KB
testcase_02 AC 2 ms
5,460 KB
testcase_03 AC 2 ms
5,400 KB
testcase_04 AC 2 ms
5,460 KB
testcase_05 AC 2 ms
5,464 KB
testcase_06 AC 2 ms
5,736 KB
testcase_07 AC 2 ms
5,452 KB
testcase_08 MLE -
testcase_09 AC 3 ms
7,976 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 194 ms
127,784 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 121 ms
97,584 KB
testcase_17 AC 134 ms
106,860 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 3 ms
7,720 KB
testcase_21 MLE -
testcase_22 AC 3 ms
7,740 KB
testcase_23 AC 2 ms
5,440 KB
testcase_24 AC 2 ms
5,396 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

template<int MOD> struct MInt {
  long long val;
  constexpr MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; }
  MInt operator+(const MInt& n) const { return MInt(val) += n; }
  MInt operator*(const MInt& n) const { return MInt(val) *= n; }
  MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; }
  MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; }
  friend ostream& operator<<(ostream& os, const MInt& n) { os<<n.val; return os; }
};
using mint = MInt<998244353>;

int N, Q;
int A[6000];
mint dp[6000][6000];
bool visited[6000][6000];
mint dfs(int i, int candidate) {
  if (N-i < candidate)
    return 0;
  if (i == N)
    return candidate == 0;
  if (visited[i][candidate])
    return dp[i][candidate];
  visited[i][candidate] = true;
  return dp[i][candidate] = dfs(i+1, candidate-1) + dfs(i+1, candidate) * (A[i]-1);
}
int main() {
  ins(N, Q);

  rep(i, N) {
    cin >> A[i];
  }
  rep(q, Q) {
    int B; cin >> B;
    cout << dfs(0, B) << endl;
  }

  return 0;
}
0