結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー mfbgjsczmfbgjscz
提出日時 2020-05-01 17:56:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,438 bytes
コンパイル時間 1,647 ms
コンパイル使用メモリ 167,832 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 19:43:09
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 66 ms
5,376 KB
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 14 ms
5,376 KB
testcase_13 AC 18 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 45 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 10 ms
5,376 KB
testcase_18 AC 42 ms
5,376 KB
testcase_19 AC 17 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 33 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 67 ms
5,376 KB
testcase_26 AC 67 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  Vec(P,lli,N,0);
  Vec(Q,lli,M,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,M)cin >> Q[i];
  Vec(dp,lli,N+1,0);
  dp[0]=P[0]-1;
  dp[1]=1;
  rep(i,1,N)rrep(j,N+1,0){
    if(!j)dp[j]=(dp[j]*(P[i]-1))%mod;
    else dp[j]=((dp[j-1]+dp[j]*(P[i]-1)))%mod;
  }
  rep(i,0,M)Out(dp[Q[i]]%mod);
}
0