結果

問題 No.1702 count good string
ユーザー phsplsphspls
提出日時 2022-10-01 19:01:21
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,861 bytes
コンパイル時間 1,035 ms
コンパイル使用メモリ 151,040 KB
実行使用メモリ 29,848 KB
最終ジャッジ日時 2023-08-25 16:57:09
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,384 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 47 ms
29,632 KB
testcase_44 AC 47 ms
29,556 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,380 KB
testcase_49 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable `LIMIT` should have a snake case name
  --> Main.rs:12:9
   |
12 |     let LIMIT = 10;
   |         ^^^^^ help: convert the identifier to snake case: `limit`
   |
   = note: `#[warn(non_snake_case)]` on by default

warning: 1 warning emitted

ソースコード

diff #

const MOD: usize = 1e9 as usize + 7;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s = s.trim().chars().collect::<Vec<char>>();

    let LIMIT = 10;
    let mut dp = vec![vec![vec![0usize; LIMIT]; 2]; n+1];
    dp[0][0][0] = 1;
    for i in 0..n {
        for pat in 0..2 {
            for j in 0..LIMIT {
                dp[i+1][pat][j] += dp[i][pat][j];
            }
            match s[i] {
                'y' => { dp[i+1][pat][1]  += dp[i][pat][0]; dp[i+1][pat][1]  %= MOD; },
                'u' => { dp[i+1][pat][2]  += dp[i][pat][1]; dp[i+1][pat][2]  %= MOD; },
                'k' => { dp[i+1][pat][3]  += dp[i][pat][2]; dp[i+1][pat][3]  %= MOD; },
                'i' => { dp[i+1][pat][4]  += dp[i][pat][3]; dp[i+1][pat][4]  %= MOD; },
                'c' => { dp[i+1][pat][5]  += dp[i][pat][4]; dp[i+1][pat][5]  %= MOD; },
                'o' => { dp[i+1][pat][6]  += dp[i][pat][5]; dp[i+1][pat][6]  %= MOD; },
                'd' => { dp[i+1][pat][7]  += dp[i][pat][6]; dp[i+1][pat][7]  %= MOD; },
                'e' => { dp[i+1][pat][8]  += dp[i][pat][7]; dp[i+1][pat][8]  %= MOD; },
                'r' => { dp[i+1][pat][9]  += dp[i][pat][8]; dp[i+1][pat][9]  %= MOD; },
                '?' => {
                    if pat == 0 {
                        for k in 0..LIMIT-1 {
                            dp[i+1][pat+1][k+1] += dp[i][pat][k];
                            dp[i+1][pat+1][k+1] %= MOD;
                        }
                    } else {
                        dp[i+1][1][0] = 25;
                    }
                },
                _ => {},
            };
        }
        
    }
    println!("{}", (dp[n][0][LIMIT-1] + dp[n][1][LIMIT-1]) % MOD);
}
0