結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー umezoumezo
提出日時 2020-05-29 23:25:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 789 bytes
コンパイル時間 2,697 ms
コンパイル使用メモリ 223,108 KB
実行使用メモリ 243,352 KB
最終ジャッジ日時 2024-04-24 01:36:16
合計ジャッジ時間 4,978 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 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 72 ms
104,224 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 MLE -
testcase_11 AC 40 ms
58,852 KB
testcase_12 AC 31 ms
45,308 KB
testcase_13 AC 41 ms
61,248 KB
testcase_14 AC 43 ms
64,700 KB
testcase_15 MLE -
testcase_16 AC 20 ms
26,984 KB
testcase_17 AC 24 ms
31,708 KB
testcase_18 MLE -
testcase_19 AC 39 ms
56,856 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 88 ms
123,180 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 #

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

#define MOD 998244353

int main(){
  ll n,q;
  cin>>n>>q;
  
  vector<ll> A(n+1);
  A[0]=0;
  rep(i,n) cin>>A[i+1];
  
  ll dp[n+1][n+1];
  rep(i,n+1) dp[i][i]=1;
  for(int i=1;i<=n;i++) dp[i][0]=dp[i-1][0]*(A[i]-1)%MOD;     
     
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      dp[i][j]=(dp[i-1][j-1]+dp[i-1][j]*(A[i]-1)%MOD)%MOD;
    }
  }
  
  int x;
  rep(i,q){
    cin>>x;
    cout<<dp[n][x]<<endl;
  }

  return 0;
}
0