結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
|
提出日時 | 2020-05-29 21:50:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 1,650 ms |
コンパイル使用メモリ | 171,984 KB |
実行使用メモリ | 284,928 KB |
最終ジャッジ日時 | 2024-11-06 03:46:59 |
合計ジャッジ時間 | 4,625 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 MLE * 6 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair<int,int> ; using pll = pair<long long,long long>; using vc = pair<ll,vector<ll>>; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 998244353; int main(){ int n,q; cin >> n >> q; vector<ll> a(n),b(q); rep(i,n) cin >> a[i]; rep(i,q) cin >> b[i]; vector<vector<ll>> dp(n+1,vector<ll>(n+1,0)); dp[0][0] = 1; for(int i=1;i<=n;i++){ rep(j,n+1){ if(j > 0) dp[i][j] = ((dp[i-1][j]*(a[i-1]-1))%MOD + dp[i-1][j-1])%MOD; else dp[i][j] = (dp[i-1][j]*(a[i-1]-1))%MOD; } } rep(i,q){ cout << dp[n][b[i]] << '\n' ; } return 0; }