結果

問題 No.1702 count good string
ユーザー tentententen
提出日時 2021-11-29 17:15:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,789 bytes
コンパイル時間 3,519 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 53,280 KB
最終ジャッジ日時 2023-09-15 08:45:39
合計ジャッジ時間 9,200 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,392 KB
testcase_01 AC 44 ms
49,508 KB
testcase_02 AC 44 ms
49,276 KB
testcase_03 AC 46 ms
49,348 KB
testcase_04 AC 46 ms
49,320 KB
testcase_05 AC 44 ms
49,220 KB
testcase_06 AC 46 ms
49,312 KB
testcase_07 AC 45 ms
49,292 KB
testcase_08 AC 44 ms
49,296 KB
testcase_09 AC 43 ms
49,536 KB
testcase_10 AC 43 ms
49,304 KB
testcase_11 AC 43 ms
49,308 KB
testcase_12 AC 43 ms
49,216 KB
testcase_13 AC 116 ms
51,176 KB
testcase_14 AC 114 ms
52,848 KB
testcase_15 AC 118 ms
52,408 KB
testcase_16 AC 118 ms
52,728 KB
testcase_17 AC 117 ms
53,280 KB
testcase_18 AC 115 ms
52,960 KB
testcase_19 AC 118 ms
52,864 KB
testcase_20 AC 116 ms
52,148 KB
testcase_21 AC 117 ms
52,388 KB
testcase_22 AC 118 ms
53,024 KB
testcase_23 AC 46 ms
49,504 KB
testcase_24 AC 48 ms
49,368 KB
testcase_25 AC 45 ms
49,764 KB
testcase_26 AC 47 ms
49,372 KB
testcase_27 AC 45 ms
49,292 KB
testcase_28 AC 45 ms
49,400 KB
testcase_29 AC 46 ms
49,232 KB
testcase_30 AC 46 ms
49,288 KB
testcase_31 AC 45 ms
49,456 KB
testcase_32 AC 45 ms
49,408 KB
testcase_33 AC 109 ms
52,520 KB
testcase_34 AC 102 ms
52,772 KB
testcase_35 AC 112 ms
52,964 KB
testcase_36 AC 112 ms
52,804 KB
testcase_37 AC 113 ms
52,796 KB
testcase_38 AC 105 ms
52,500 KB
testcase_39 AC 112 ms
52,776 KB
testcase_40 AC 111 ms
52,796 KB
testcase_41 AC 112 ms
52,472 KB
testcase_42 AC 110 ms
52,932 KB
testcase_43 AC 102 ms
52,528 KB
testcase_44 AC 123 ms
52,912 KB
testcase_45 AC 42 ms
49,180 KB
testcase_46 AC 42 ms
49,320 KB
testcase_47 AC 43 ms
49,220 KB
testcase_48 AC 42 ms
49,520 KB
testcase_49 AC 45 ms
49,300 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 yukicoder = "yukicoder";
        int length = yukicoder.length();
        HashMap<Character, Integer> idxes = new HashMap<>();
        for (int i = 0; i < length; i++) {
            idxes.put(yukicoder.charAt(i), i + 1);
        }
        int[][] dp = new int[length + 1][2];
        dp[0][0] = 1;
        for (char c : sc.next().toCharArray()) {
            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;
            } else if (c == '?') {
                for (int i = 1; i <= length; i++) {
                    dp[i][1] += dp[i - 1][0];
                    dp[i][1] %= MOD;
                }
            }
        }
        System.out.println((dp[length][0] + dp[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 next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0