結果
問題 | No.1492 01文字列と転倒 |
ユーザー |
|
提出日時 | 2023-01-17 02:09:37 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1,767 ms / 4,000 ms |
コード長 | 896 bytes |
コンパイル時間 | 12,316 ms |
コンパイル使用メモリ | 402,172 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-12-31 20:23:29 |
合計ジャッジ時間 | 27,121 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
warning: unused variable: `i` --> src/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 --> 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]; | ~~~~~ warning: variable `LIMIT` should have a snake case name --> src/main.rs:9:9 | 9 | let LIMIT = (0..n).sum::<usize>(); | ^^^^^ help: convert the identifier to snake case: `limit`
ソースコード
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");}}