結果
| 問題 |
No.1068 #いろいろな色 / Red and Blue and more various colors (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 22:12:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,486 bytes |
| コンパイル時間 | 1,719 ms |
| コンパイル使用メモリ | 171,864 KB |
| 実行使用メモリ | 13,768 KB |
| 最終ジャッジ日時 | 2024-11-06 05:06:25 |
| 合計ジャッジ時間 | 7,984 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 TLE * 1 -- * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=998244353;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
const int nmax=20005;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<nmax;i++){
fac[i]=fac[i-1]*i%mod;
inv[i]=mod-inv[mod%i]*(mod/i)%mod;
finv[i]=finv[i-1]*inv[i]%mod;
}
}
// modintを使うときはllをmintに
ll com(int n,int k){
if(n<k||n<0||k<0){
return 0;
}
return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,q;cin >> n >> q;
vector<int> a(n);
ll mul=1;
rep(i,n){
cin >> a[i];
a[i]%=mod;
}
vector<ll> dp(n+1,-1);
dp[0]=1;
for(int i=0;i<n;i++){
vector<ll> tmp(n+1);
for(int j=0;j<=n;j++){
if(dp[j]==-1){
continue;
}
(tmp[j]+=dp[j])%=mod;
(tmp[j+1]+=(dp[j]*(a[i]-1+mod)%mod)%mod)%=mod;
}
for(int j=0;j<=n;j++){
dp[j]=tmp[j];
}
}
rep(i,q){
int b;cin >> b;
cout << dp[n-b] << endl;
}
}