結果

問題 No.1702 count good string
ユーザー tentententen
提出日時 2021-11-09 15:02:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,893 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 78,940 KB
実行使用メモリ 39,708 KB
最終ジャッジ日時 2024-04-29 10:19:55
合計ジャッジ時間 8,503 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,584 KB
testcase_01 AC 53 ms
36,864 KB
testcase_02 AC 52 ms
37,248 KB
testcase_03 AC 52 ms
36,952 KB
testcase_04 AC 52 ms
36,816 KB
testcase_05 AC 52 ms
36,952 KB
testcase_06 AC 53 ms
37,128 KB
testcase_07 AC 51 ms
37,048 KB
testcase_08 AC 51 ms
37,120 KB
testcase_09 AC 51 ms
37,124 KB
testcase_10 AC 54 ms
37,100 KB
testcase_11 AC 53 ms
36,704 KB
testcase_12 AC 52 ms
37,064 KB
testcase_13 AC 121 ms
39,508 KB
testcase_14 AC 122 ms
39,228 KB
testcase_15 AC 123 ms
39,540 KB
testcase_16 AC 122 ms
39,564 KB
testcase_17 AC 124 ms
39,412 KB
testcase_18 AC 122 ms
39,388 KB
testcase_19 AC 124 ms
39,332 KB
testcase_20 AC 123 ms
39,408 KB
testcase_21 AC 123 ms
39,524 KB
testcase_22 AC 125 ms
39,468 KB
testcase_23 AC 54 ms
37,024 KB
testcase_24 AC 54 ms
37,076 KB
testcase_25 AC 53 ms
36,944 KB
testcase_26 AC 53 ms
36,876 KB
testcase_27 AC 52 ms
37,004 KB
testcase_28 AC 52 ms
36,856 KB
testcase_29 AC 53 ms
37,236 KB
testcase_30 AC 53 ms
36,912 KB
testcase_31 AC 53 ms
37,032 KB
testcase_32 AC 52 ms
36,920 KB
testcase_33 AC 108 ms
39,452 KB
testcase_34 AC 112 ms
39,176 KB
testcase_35 AC 117 ms
39,448 KB
testcase_36 AC 117 ms
39,224 KB
testcase_37 AC 120 ms
39,260 KB
testcase_38 AC 117 ms
39,452 KB
testcase_39 AC 124 ms
39,380 KB
testcase_40 AC 112 ms
39,212 KB
testcase_41 AC 122 ms
39,708 KB
testcase_42 AC 122 ms
39,388 KB
testcase_43 AC 117 ms
39,312 KB
testcase_44 AC 127 ms
39,604 KB
testcase_45 AC 52 ms
37,132 KB
testcase_46 AC 52 ms
37,004 KB
testcase_47 AC 51 ms
37,132 KB
testcase_48 AC 50 ms
36,608 KB
testcase_49 AC 51 ms
37,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        char[] yukicoder = "yukicoder".toCharArray();
        HashMap<Character, Integer> idxes = new HashMap<>();
        for (int i = 0; i < yukicoder.length; i++) {
            idxes.put(yukicoder[i], i + 1);
        }
        int[][] dp = new int[yukicoder.length + 1][2];
        dp[0][0] = 1;
        for (char c : sc.next().toCharArray()) {
            if (c == '?') {
                for (int i = 1; i <= yukicoder.length; i++) {
                    dp[i][1] += dp[i - 1][0];
                    dp[i][1] %= MOD;
                }
            } else if (idxes.containsKey(c)) {
                int x = idxes.get(c);
                dp[x][0] += dp[x - 1][0];
                dp[x][0] %= MOD;
                dp[x][1] += dp[x - 1][1];
                dp[x][1] %= MOD;
            }
        }
        System.out.println((dp[yukicoder.length][0] + dp[yukicoder.length][1]) % 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 double nextDouble() throws Exception {
        return Double.parseDouble(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