結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
queee
|
| 提出日時 | 2020-05-29 23:16:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 2,000 ms |
| コード長 | 1,387 bytes |
| コンパイル時間 | 869 ms |
| コンパイル使用メモリ | 84,560 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-06 07:52:01 |
| 合計ジャッジ時間 | 2,649 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <functional>
#define DB puts("D")
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
template<typename T> void input(T a[], int n){for(int i=0;i<n;i++) cin>>a[i];}
template<typename T, typename U> void input(T a[], U b[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}
template<typename T, typename U, typename O> void input(T a[], U b[], O[], int n){for(int i=0;i<n;i++) cin>>a[i]>>b[i];}
using P=pair<double,int>;
const ll M = 998244353;
int main() {
int n,q; cin>>n>>q;
ll p[2][n+1]; fill(p[0],p[2],0LL); p[0][0]=1;
ll a[n],b[q]; input(a,n); input(b,q);
for(int i=0;i<n;i++) {
int nw = i%2, nx = (i+1)%2;
fill(p[nx],p[nx+1],0LL);
for(int j=0;j<n;j++) {
p[nx][j] += p[nw][j];
p[nx][j+1] += p[nw][j] * (a[i]-1);
p[nx][j] %= M;
p[nx][j+1] %= M;
}
}
for(int i=0;i<q;i++) {
cout<<p[n%2][n-b[i]]<<endl;
}
}
queee