結果

問題 No.1111 コード進行
ユーザー phsplsphspls
提出日時 2020-07-25 22:33:20
言語 Rust
(1.77.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 1,160 ms
コンパイル使用メモリ 145,548 KB
実行使用メモリ 217,048 KB
最終ジャッジ日時 2023-09-10 02:04:15
合計ジャッジ時間 5,365 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 5 ms
6,148 KB
testcase_07 AC 5 ms
5,540 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 7 ms
8,012 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 5 ms
6,072 KB
testcase_13 AC 4 ms
4,796 KB
testcase_14 AC 9 ms
8,536 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 6 ms
6,684 KB
testcase_17 AC 8 ms
8,272 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 10 ms
10,372 KB
testcase_23 AC 4 ms
4,676 KB
testcase_24 AC 4 ms
5,616 KB
testcase_25 AC 10 ms
9,860 KB
testcase_26 AC 7 ms
6,020 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 106 ms
108,848 KB
testcase_29 AC 44 ms
45,524 KB
testcase_30 AC 102 ms
72,376 KB
testcase_31 AC 14 ms
13,560 KB
testcase_32 AC 101 ms
64,776 KB
testcase_33 AC 84 ms
42,576 KB
testcase_34 AC 74 ms
78,496 KB
testcase_35 AC 96 ms
100,140 KB
testcase_36 AC 103 ms
107,520 KB
testcase_37 AC 26 ms
27,044 KB
testcase_38 AC 36 ms
20,356 KB
testcase_39 AC 143 ms
71,276 KB
testcase_40 AC 160 ms
98,284 KB
testcase_41 AC 114 ms
120,388 KB
testcase_42 AC 47 ms
49,240 KB
testcase_43 AC 79 ms
43,104 KB
testcase_44 AC 22 ms
23,860 KB
testcase_45 AC 70 ms
73,132 KB
testcase_46 AC 3 ms
4,380 KB
testcase_47 AC 205 ms
217,048 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
}
0