結果

問題 No.1702 count good string
ユーザー phsplsphspls
提出日時 2022-10-02 01:26:07
言語 Rust
(1.77.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,810 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 146,108 KB
実行使用メモリ 29,784 KB
最終ジャッジ日時 2023-08-25 21:20:43
合計ジャッジ時間 4,756 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 51 ms
29,584 KB
testcase_14 AC 50 ms
29,592 KB
testcase_15 AC 51 ms
29,584 KB
testcase_16 AC 50 ms
29,536 KB
testcase_17 AC 49 ms
29,596 KB
testcase_18 AC 51 ms
29,536 KB
testcase_19 AC 50 ms
29,624 KB
testcase_20 AC 50 ms
29,552 KB
testcase_21 AC 50 ms
29,540 KB
testcase_22 AC 51 ms
29,548 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 47 ms
29,620 KB
testcase_34 AC 48 ms
29,592 KB
testcase_35 AC 49 ms
29,612 KB
testcase_36 AC 50 ms
29,612 KB
testcase_37 AC 49 ms
29,636 KB
testcase_38 AC 49 ms
29,784 KB
testcase_39 AC 49 ms
29,608 KB
testcase_40 AC 51 ms
29,556 KB
testcase_41 AC 53 ms
29,624 KB
testcase_42 AC 50 ms
29,608 KB
testcase_43 AC 54 ms
29,612 KB
testcase_44 AC 50 ms
29,556 KB
testcase_45 AC 1 ms
4,380 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];
                dp[i+1][pat][j] %= MOD;
            }
            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;
                        }
                    }
                },
                _ => {},
            };
        }
        
    }
    println!("{}", (dp[n][0][LIMIT-1] + dp[n][1][LIMIT-1]) % MOD);
}
0