結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー okok
提出日時 2020-05-29 23:40:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 943 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 90,368 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 02:03:42
合計ジャッジ時間 2,239 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 24 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 59 ms
6,940 KB
testcase_11 AC 15 ms
6,944 KB
testcase_12 AC 11 ms
6,944 KB
testcase_13 AC 15 ms
6,944 KB
testcase_14 AC 16 ms
6,944 KB
testcase_15 AC 40 ms
6,940 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 9 ms
6,940 KB
testcase_18 AC 37 ms
6,944 KB
testcase_19 AC 14 ms
6,944 KB
testcase_20 AC 2 ms
6,948 KB
testcase_21 AC 29 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 61 ms
6,940 KB
testcase_26 AC 61 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, Q;
	vector<int> A, B;
	vector<vector<int>> dp;
	
	cin>>N>>Q;
	
	A.resize(N);
	B.resize(Q);
	dp.resize(2, vector<int>(N+1));

	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	dp[0][0] = 1;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++){
			dp[(i+1)%2][j] += dp[(i)%2][j] * (A[i] - 1);
			dp[(i+1)%2][j+1] += dp[(i)%2][j];
			dp[(i+1)%2][j] %= MOD;
			dp[(i+1)%2][j+1] %= MOD;
			
			dp[i%2][j] = 0;
		}
	}

	for(int i = 0; i < Q; i++){
		cin>>B[i];
		
		cout<<dp[N%2][B[i]]<<endl;
	}
	
	return 0;
}
0