結果
問題 |
No.1111 コード進行
|
ユーザー |
|
提出日時 | 2020-07-25 22:33:20 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 210 ms / 2,000 ms |
コード長 | 1,267 bytes |
コンパイル時間 | 17,338 ms |
コンパイル使用メモリ | 378,448 KB |
実行使用メモリ | 217,088 KB |
最終ジャッジ日時 | 2024-06-27 18:10:06 |
合計ジャッジ時間 | 16,534 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
ソースコード
fn main() { let mut nmk = String::new(); std::io::stdin().read_line(&mut nmk).ok(); let nmk: Vec<usize> = nmk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nmk[0]; let m = nmk[1]; let k = nmk[2]; let mut progress: Vec<Vec<(usize, usize)>> = vec![vec![]; 300]; for _ in 0..m { let mut pqc = String::new(); std::io::stdin().read_line(&mut pqc).ok(); let pqc: Vec<usize> = pqc.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); progress[pqc[0] - 1].push((pqc[1] - 1, pqc[2])); } const DIVISOR: usize = 1e9 as usize + 7usize; let mut dp: Vec<Vec<Vec<usize>>> = vec![vec![vec![0; 300]; k+1]; n]; for i in 0..300 { dp[0][0][i] = 1; } for i in 1..n { for c in 0..=k { for m in 0..300 { if dp[i-1][c][m] == 0 { continue; } progress[m].iter() .filter(|&pair| pair.1 + c <= k) .for_each(|&pair| { dp[i][c + pair.1][pair.0] += dp[i-1][c][m]; dp[i][c + pair.1][pair.0] %= DIVISOR; }); } } } println!("{}", dp[n-1][k].iter().sum::<usize>() % DIVISOR); }