結果
| 問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-29 23:45:28 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 899 bytes |
| 記録 | |
| コンパイル時間 | 13,728 ms |
| コンパイル使用メモリ | 386,276 KB |
| 実行使用メモリ | 283,520 KB |
| 最終ジャッジ日時 | 2024-11-06 08:50:17 |
| 合計ジャッジ時間 | 17,424 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 MLE * 5 |
ソースコード
use std::io::*;
const MOD: usize = 998244353;
fn main() {
let mut s: String = String::new();
std::io::stdin().read_to_string(&mut s).ok();
let mut itr = s.trim().split_whitespace();
let n: usize = itr.next().unwrap().parse().unwrap();
let q: usize = itr.next().unwrap().parse().unwrap();
let a: Vec<usize> = (0..n)
.map(|_| itr.next().unwrap().parse::<usize>().unwrap() - 1)
.collect();
let b: Vec<usize> = (0..q)
.map(|_| itr.next().unwrap().parse().unwrap())
.collect();
let mut dp: Vec<Vec<usize>> = vec![vec![0; n + 1]; n + 1];
dp[0][0] = 1;
for i in 0..n {
for j in 0..n {
dp[i + 1][j + 1] += dp[i][j];
dp[i + 1][j + 1] %= MOD;
dp[i + 1][j] += dp[i][j] * a[i];
dp[i + 1][j] %= MOD;
}
}
for i in 0..q {
println!("{}", dp[n][b[i]]);
}
}