結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー queeequeee
提出日時 2020-05-29 23:16:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,387 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 84,932 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 01:15:51
合計ジャッジ時間 2,489 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 45 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 107 ms
5,376 KB
testcase_11 AC 26 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 27 ms
5,376 KB
testcase_14 AC 28 ms
5,376 KB
testcase_15 AC 74 ms
5,376 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 15 ms
5,376 KB
testcase_18 AC 70 ms
5,376 KB
testcase_19 AC 25 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 51 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 108 ms
5,376 KB
testcase_26 AC 109 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  }
}
0