結果
問題 | No.1492 01文字列と転倒 |
ユーザー |
|
提出日時 | 2023-02-07 02:21:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 656 ms / 4,000 ms |
コード長 | 1,082 bytes |
コンパイル時間 | 12,448 ms |
コンパイル使用メモリ | 383,800 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-07-05 02:36:05 |
合計ジャッジ時間 | 18,901 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
warning: unused variable: `i` --> src/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 --> src/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]; | ~~~~~
ソースコード
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![0usize; limit+1]; n+1];dp[0][0] = 1;for i in 1..2*n {let mut next_dp = vec![vec![0usize; limit+1]; n+1];for j in 0..=n {for cnt in 0..=limit {if dp[j][cnt] == 0 { continue; }next_dp[j][cnt] += dp[j][cnt];next_dp[j][cnt] %= MOD;if j < n && (i+1)/2 >= j+1 {let zero_used = i - j;if cnt+n >= zero_used {next_dp[j+1][cnt+n-zero_used] += dp[j][cnt];next_dp[j+1][cnt+n-zero_used] %= MOD;}}}}dp = next_dp;}for i in 0..=limit {println!("{}", dp[n][i]);}for i in limit+1..=n*n {println!("0");}}