結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 22:27:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,060 bytes |
| コンパイル時間 | 1,552 ms |
| コンパイル使用メモリ | 167,872 KB |
| 実行使用メモリ | 95,872 KB |
| 最終ジャッジ日時 | 2024-11-06 05:47:14 |
| 合計ジャッジ時間 | 3,287 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 21 |
ソースコード
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
int dp[6010][6010] = {};
void solve(){
ll N,Q;
cin >> N >> Q;
int A[200010];
int B[200010];
rep(i,0,N) cin >> A[i];
rep(i,0,Q) cin >> B[i];
dp[0][1] = A[0]-1;
rep(i,1,N){
dp[i][1] = dp[i-1][1] + A[i]-1;
dp[i][1] %= MOD;
}
rep(i,0,N){
rep(j,2,N+1){
if(j > i+1) continue;
dp[i][j] = (dp[i-1][j] + dp[i-1][j-1] * (A[i]-1) % MOD) % MOD;
}
}
dp[N-1][0] = 1;
rep(i,0,Q){
print(dp[N-1][N - B[i]]);
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
solve();
}