結果

問題 No.1492 01文字列と転倒
ユーザー phsplsphspls
提出日時 2023-01-11 01:42:03
言語 Rust
(1.77.0)
結果
AC  
実行時間 509 ms / 4,000 ms
コード長 1,039 bytes
コンパイル時間 3,028 ms
コンパイル使用メモリ 140,440 KB
実行使用メモリ 9,744 KB
最終ジャッジ日時 2023-08-23 11:48:55
合計ジャッジ時間 7,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 504 ms
9,744 KB
testcase_03 AC 476 ms
9,200 KB
testcase_04 AC 434 ms
8,752 KB
testcase_05 AC 367 ms
8,052 KB
testcase_06 AC 378 ms
8,236 KB
testcase_07 AC 416 ms
8,660 KB
testcase_08 AC 509 ms
9,664 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,504 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 382 ms
8,240 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 364 ms
8,060 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 303 ms
7,172 KB
testcase_22 AC 7 ms
4,380 KB
testcase_23 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> Main.rs:33:9
   |
33 |     for i in limit+1..=n*n {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: variable `MOD` should have a snake case name
 --> Main.rs:7:9
  |
7 |     let MOD = nm[1];
  |         ^^^
  |
  = note: `#[warn(non_snake_case)]` on by default
help: rename the identifier or convert it to a snake case raw identifier
  |
7 |     let r#mod = nm[1];
  |         ~~~~~

warning: 2 warnings emitted

ソースコード

diff #

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

    let limit = (0..n).sum::<usize>();
    let mut dp = vec![vec![0usize; limit+1]; n+1];
    dp[1][0] = 1;
    for ccnt in 1..2*n {
        let mut next_dp = vec![vec![0usize; limit+1]; n+1];
        for i in 0..=n {
            for j in 0..=limit {
                if dp[i][j] == 0 { continue; }
                if i+1 <= n {
                    next_dp[i+1][j] += dp[i][j];
                    next_dp[i+1][j] %= MOD;
                }
                if i >= ccnt-i+1 {
                    let inv_val = n - i;
                    next_dp[i][j+inv_val] += dp[i][j];
                    next_dp[i][j+inv_val] %= MOD;
                }
            }
        }
        dp = next_dp;
    }
    for i in 0..=limit {
        println!("{}", dp[n][i]);
    }
    for i in limit+1..=n*n {
        println!("0");
    }
}
0