結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー autumn-eelautumn-eel
提出日時 2020-05-29 21:30:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 163,480 KB
実行使用メモリ 95,808 KB
最終ジャッジ日時 2023-08-05 23:48:57
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 74 ms
43,296 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 179 ms
93,416 KB
testcase_11 AC 45 ms
28,592 KB
testcase_12 AC 38 ms
23,468 KB
testcase_13 AC 50 ms
29,264 KB
testcase_14 AC 50 ms
30,440 KB
testcase_15 AC 133 ms
67,600 KB
testcase_16 AC 24 ms
16,588 KB
testcase_17 AC 26 ms
18,368 KB
testcase_18 AC 115 ms
62,992 KB
testcase_19 AC 45 ms
27,732 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 98 ms
50,632 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 190 ms
95,808 KB
testcase_26 AC 67 ms
27,484 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[6010][6010];
int a[6010];

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