結果

問題 No.1492 01文字列と転倒
ユーザー phsplsphspls
提出日時 2023-01-17 02:09:37
言語 Rust
(1.77.0)
結果
AC  
実行時間 1,862 ms / 4,000 ms
コード長 896 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 148,024 KB
実行使用メモリ 9,532 KB
最終ジャッジ日時 2023-08-30 07:01:33
合計ジャッジ時間 17,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1,858 ms
9,504 KB
testcase_03 AC 1,665 ms
9,312 KB
testcase_04 AC 1,481 ms
8,784 KB
testcase_05 AC 1,192 ms
7,988 KB
testcase_06 AC 1,256 ms
8,252 KB
testcase_07 AC 1,418 ms
8,492 KB
testcase_08 AC 1,862 ms
9,532 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1,268 ms
8,252 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 12 ms
4,376 KB
testcase_17 AC 1,190 ms
7,996 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 937 ms
7,180 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> Main.rs:29:9
   |
29 |     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: variable `LIMIT` should have a snake case name
 --> Main.rs:9:9
  |
9 |     let LIMIT = (0..n).sum::<usize>();
  |         ^^^^^ help: convert the identifier to snake case: `limit`

warning: 3 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]; 1];
    dp[0][0] = 1;
    for i in 1..=n {
        let mut next_dp = vec![vec![0usize; LIMIT+1]; i+1];
        for j in 0..i {
            for k in 0..=LIMIT {
                if dp[j][k] == 0 { continue; }
                for nj in j..=i {
                    let diff = (nj - j) * (n - i);
                    next_dp[nj][diff+k] += dp[j][k];
                    next_dp[nj][diff+k] %= MOD;
                }
            }
        }
        dp = next_dp;
    }
    for i in 0..=LIMIT {
        println!("{}", dp[n][i]);
    }
    for i in LIMIT+1..=n*n {
        println!("0");
    }
}
0