結果

問題 No.1492 01文字列と転倒
ユーザー phsplsphspls
提出日時 2023-02-07 02:19:29
言語 Rust
(1.77.0)
結果
MLE  
実行時間 -
コード長 1,030 bytes
コンパイル時間 7,152 ms
コンパイル使用メモリ 145,936 KB
実行使用メモリ 787,864 KB
最終ジャッジ日時 2023-09-18 11:27:44
合計ジャッジ時間 18,541 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 MLE -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 17 ms
12,616 KB
testcase_17 MLE -
testcase_18 AC 19 ms
13,972 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 13 ms
9,424 KB
testcase_21 AC 686 ms
473,660 KB
testcase_22 AC 17 ms
12,612 KB
testcase_23 AC 8 ms
6,072 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> Main.rs:31:9
   |
31 |     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 = n * (n-1) / 2;
    let mut dp = vec![vec![vec![0usize; limit+1]; n+1]; 2*n+1];
    dp[1][0][0] = 1;
    for i in 1..2*n {
        for j in 0..=n {
            for cnt in 0..=limit {
                if dp[i][j][cnt] == 0 { continue; }
                dp[i+1][j][cnt] += dp[i][j][cnt];
                dp[i+1][j][cnt] %= MOD;
                if j < n && (i+1)/2 >= j+1 {
                    let zero_used = i - j;
                    if cnt+n >= zero_used {
                        dp[i+1][j+1][cnt+n-zero_used] += dp[i][j][cnt];
                        dp[i+1][j+1][cnt+n-zero_used] %= MOD;
                    }
                }
            }
        }
    }
    for i in 0..=limit {
        println!("{}", dp[2*n][n][i]);
    }
    for i in limit+1..=n*n {
        println!("0");
    }
}
0