結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー phsplsphspls
提出日時 2022-10-05 12:36:18
言語 Rust
(1.77.0)
結果
AC  
実行時間 998 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 144,604 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 04:22:55
合計ジャッジ時間 14,730 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 52 ms
4,380 KB
testcase_02 AC 112 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 588 ms
4,376 KB
testcase_06 AC 74 ms
4,380 KB
testcase_07 AC 772 ms
4,376 KB
testcase_08 AC 193 ms
4,376 KB
testcase_09 AC 291 ms
4,380 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 773 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 26 ms
4,380 KB
testcase_14 AC 83 ms
4,376 KB
testcase_15 AC 904 ms
4,380 KB
testcase_16 AC 970 ms
4,380 KB
testcase_17 AC 899 ms
4,380 KB
testcase_18 AC 951 ms
4,376 KB
testcase_19 AC 994 ms
4,380 KB
testcase_20 AC 868 ms
4,380 KB
testcase_21 AC 869 ms
4,376 KB
testcase_22 AC 511 ms
4,380 KB
testcase_23 AC 872 ms
4,380 KB
testcase_24 AC 998 ms
4,376 KB
testcase_25 AC 268 ms
4,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const MOD: usize = 1e9 as usize + 7;

fn main() {
    let mut nkl = String::new();
    std::io::stdin().read_line(&mut nkl).ok();
    let nkl: Vec<usize> = nkl.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nkl[0];
    let k = nkl[1];
    let l = nkl[2];

    let mut dp = vec![0usize; n];
    dp[0] = 1;
    for _ in 0..k {
        let mut next_dp = vec![0usize; n];
        for j in 0..n {
            if dp[j] == 0 { continue; }
            let start = j+1;
            let end = j+l+1;
            if l == n {
                next_dp[0] += dp[j];
                continue;
            }
            let start = if start >= n { start % n } else { start };
            let end = if end >= n { end % n } else { end };
            if start > end {
                next_dp[0] += dp[j];
            }
            next_dp[start] += dp[j];
            next_dp[end] += MOD - dp[j];
        }
        next_dp[0] %= MOD;
        for j in 0..n-1 {
            next_dp[j+1] += next_dp[j];
            next_dp[j+1] %= MOD;
        }
        dp = next_dp;
    }
    for &v in dp.iter() {
        println!("{}", v);
    }
}
0