結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー autumn-eelautumn-eel
提出日時 2020-05-29 21:29:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 201 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 162,332 KB
実行使用メモリ 96,640 KB
最終ジャッジ日時 2024-04-23 20:15:37
合計ジャッジ時間 3,689 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 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 81 ms
43,648 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 193 ms
94,080 KB
testcase_11 AC 48 ms
28,672 KB
testcase_12 AC 39 ms
23,680 KB
testcase_13 AC 50 ms
29,312 KB
testcase_14 AC 54 ms
30,464 KB
testcase_15 AC 132 ms
67,840 KB
testcase_16 AC 25 ms
16,896 KB
testcase_17 AC 29 ms
18,688 KB
testcase_18 AC 122 ms
63,104 KB
testcase_19 AC 47 ms
27,776 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 96 ms
50,816 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 201 ms
96,640 KB
testcase_26 AC 70 ms
27,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int dp[6200][6200];
int a[7000];

int main(){
	int n,q;cin>>n>>q;
	rep(i,n)scanf("%d",&a[i]);
	dp[0][0]=1;
	rep(i,n)rep(j,n){
		if(dp[i][j]==0)continue;
		(dp[i+1][j+1]+=dp[i][j])%=MOD;
		(dp[i+1][j]+=dp[i][j]*(ll)(a[i]-1)%MOD)%=MOD;
	}
	rep(i,q){
		int b;scanf("%d",&b);
		printf("%d\n",dp[n][b]);
	}
}
0