結果

問題 No.1702 count good string
ユーザー tentententen
提出日時 2021-10-18 19:40:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,758 bytes
コンパイル時間 2,764 ms
コンパイル使用メモリ 78,340 KB
実行使用メモリ 55,728 KB
最終ジャッジ日時 2023-10-19 19:39:26
合計ジャッジ時間 10,352 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
53,484 KB
testcase_01 AC 56 ms
53,480 KB
testcase_02 AC 55 ms
53,440 KB
testcase_03 AC 59 ms
53,504 KB
testcase_04 AC 57 ms
53,428 KB
testcase_05 AC 56 ms
53,496 KB
testcase_06 AC 55 ms
53,492 KB
testcase_07 AC 58 ms
53,488 KB
testcase_08 AC 59 ms
53,492 KB
testcase_09 AC 57 ms
53,496 KB
testcase_10 AC 58 ms
52,408 KB
testcase_11 AC 54 ms
52,364 KB
testcase_12 AC 56 ms
53,484 KB
testcase_13 AC 128 ms
55,536 KB
testcase_14 AC 133 ms
55,448 KB
testcase_15 AC 131 ms
55,500 KB
testcase_16 AC 130 ms
55,496 KB
testcase_17 AC 130 ms
55,612 KB
testcase_18 AC 129 ms
55,596 KB
testcase_19 AC 132 ms
55,648 KB
testcase_20 AC 132 ms
55,440 KB
testcase_21 AC 131 ms
55,664 KB
testcase_22 AC 126 ms
55,404 KB
testcase_23 AC 57 ms
53,500 KB
testcase_24 AC 55 ms
53,492 KB
testcase_25 AC 55 ms
53,492 KB
testcase_26 AC 57 ms
53,504 KB
testcase_27 AC 57 ms
53,500 KB
testcase_28 AC 57 ms
53,500 KB
testcase_29 AC 55 ms
53,500 KB
testcase_30 AC 55 ms
53,492 KB
testcase_31 AC 57 ms
53,500 KB
testcase_32 AC 60 ms
53,492 KB
testcase_33 AC 126 ms
55,728 KB
testcase_34 AC 127 ms
55,488 KB
testcase_35 AC 124 ms
55,388 KB
testcase_36 AC 125 ms
55,520 KB
testcase_37 AC 127 ms
55,604 KB
testcase_38 AC 125 ms
55,544 KB
testcase_39 AC 125 ms
55,580 KB
testcase_40 AC 109 ms
55,156 KB
testcase_41 AC 121 ms
55,428 KB
testcase_42 AC 123 ms
55,516 KB
testcase_43 AC 117 ms
55,264 KB
testcase_44 AC 135 ms
55,508 KB
testcase_45 AC 57 ms
53,488 KB
testcase_46 AC 57 ms
52,400 KB
testcase_47 AC 56 ms
53,484 KB
testcase_48 AC 59 ms
53,484 KB
testcase_49 AC 56 ms
53,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        String base = "yukicoder";
        int length = base.length();
        int[][] dp = new int[2][length + 1];
        dp[0][0] = 1;
        HashMap<Character, Integer> idxes = new HashMap<>();
        for (int i = 0; i < length; i++) {
            idxes.put(base.charAt(i), i + 1);
        }
        for (char c : sc.next().toCharArray()) {
            if (c == '?') {
                for (int i = 1; i <= length; i++) {
                    dp[1][i] += dp[0][i - 1];
                    dp[1][i] %= MOD;
                }
            } else if (idxes.containsKey(c)) {
                int x = idxes.get(c);
                dp[0][x] += dp[0][x - 1];
                dp[0][x] %= MOD;
                dp[1][x] += dp[1][x - 1];
                dp[1][x] %= MOD;
            }
        }
        System.out.println((dp[0][length] + dp[1][length]) % MOD);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0