結果
問題 |
No.2541 Divide 01 String
|
ユーザー |
|
提出日時 | 2023-12-01 06:03:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 24,007 ms |
コンパイル使用メモリ | 391,676 KB |
実行使用メモリ | 13,872 KB |
最終ジャッジ日時 | 2024-09-26 15:10:00 |
合計ジャッジ時間 | 16,635 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
warning: unused import: `proconio::marker::Usize1` --> src/main.rs:2:5 | 2 | use proconio::marker::Usize1; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unnecessary trailing semicolon --> src/main.rs:15:29 | 15 | let MOD:i64 = 998244353;; | ^ help: remove this semicolon | = note: `#[warn(redundant_semicolons)]` on by default warning: variable `MOD` should have a snake case name --> src/main.rs:15:9 | 15 | let MOD:i64 = 998244353;; | ^^^ | = note: `#[warn(non_snake_case)]` on by default help: rename the identifier or convert it to a snake case raw identifier | 15 | let r#mod:i64 = 998244353;; | ~~~~~
ソースコード
use proconio::input; use proconio::marker::Usize1; use proconio::marker::Chars; fn main() { input! { n: usize, s: Chars, }; let mut dp = vec![vec![0i64; 2]; n + 1]; dp[0][0] = 1; let MOD:i64 = 998244353;; for i in 1..=n { if s[i - 1] == '1' { dp[i][1] = dp[i - 1][0] + dp[i - 1][1]; dp[i][1] += dp[i - 1][1]; dp[i][1] %= MOD; } else { dp[i][0] = dp[i - 1][1] + dp[i - 1][0]; dp[i][1] += dp[i - 1][1]; dp[i][0] %= MOD; } } println!("{}", dp[n][1]); }