結果

問題 No.1702 count good string
ユーザー ks2mks2m
提出日時 2021-10-08 22:26:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 345 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 3,073 ms
コンパイル使用メモリ 73,956 KB
実行使用メモリ 79,860 KB
最終ジャッジ日時 2023-09-30 10:58:07
合計ジャッジ時間 14,740 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,844 KB
testcase_01 AC 123 ms
56,168 KB
testcase_02 AC 123 ms
55,852 KB
testcase_03 AC 122 ms
55,788 KB
testcase_04 AC 123 ms
55,920 KB
testcase_05 AC 123 ms
56,040 KB
testcase_06 AC 123 ms
56,092 KB
testcase_07 AC 128 ms
55,704 KB
testcase_08 AC 123 ms
56,080 KB
testcase_09 AC 123 ms
56,188 KB
testcase_10 AC 121 ms
55,500 KB
testcase_11 AC 123 ms
55,956 KB
testcase_12 AC 124 ms
56,060 KB
testcase_13 AC 299 ms
79,372 KB
testcase_14 AC 300 ms
78,684 KB
testcase_15 AC 312 ms
79,616 KB
testcase_16 AC 319 ms
79,628 KB
testcase_17 AC 321 ms
79,800 KB
testcase_18 AC 315 ms
79,632 KB
testcase_19 AC 329 ms
79,624 KB
testcase_20 AC 302 ms
79,472 KB
testcase_21 AC 301 ms
79,076 KB
testcase_22 AC 303 ms
79,232 KB
testcase_23 AC 127 ms
55,728 KB
testcase_24 AC 128 ms
56,028 KB
testcase_25 AC 127 ms
55,600 KB
testcase_26 AC 128 ms
55,860 KB
testcase_27 AC 126 ms
55,708 KB
testcase_28 AC 128 ms
55,840 KB
testcase_29 AC 127 ms
55,872 KB
testcase_30 AC 128 ms
56,084 KB
testcase_31 AC 127 ms
56,124 KB
testcase_32 AC 129 ms
55,992 KB
testcase_33 AC 305 ms
79,556 KB
testcase_34 AC 330 ms
79,520 KB
testcase_35 AC 307 ms
79,164 KB
testcase_36 AC 331 ms
79,292 KB
testcase_37 AC 345 ms
79,860 KB
testcase_38 AC 317 ms
78,988 KB
testcase_39 AC 308 ms
79,056 KB
testcase_40 AC 327 ms
79,192 KB
testcase_41 AC 298 ms
79,108 KB
testcase_42 AC 333 ms
79,336 KB
testcase_43 AC 302 ms
79,056 KB
testcase_44 AC 320 ms
79,472 KB
testcase_45 AC 123 ms
55,984 KB
testcase_46 AC 124 ms
56,148 KB
testcase_47 AC 122 ms
55,884 KB
testcase_48 AC 124 ms
56,196 KB
testcase_49 AC 124 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		char[] t = "yukicoder".toCharArray();
		int m = t.length;
		int m1 = m + 1;
		int m2 = m1 * 2;
		int mod = 1000000007;
		long[][] dp = new long[n + 1][m2];
		dp[0][0] = 1;
		for (int i = 0; i < n; i++) {
			if (s[i] == '?') {
				for (int j = 0; j < m; j++) {
					dp[i + 1][m1 + j + 1] += dp[i][j];
				}
			} else {
				for (int j = 0; j < m; j++) {
					if (s[i] == t[j]) {
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][m1 + j + 1] += dp[i][m1 + j];
					}
				}
			}
			for (int j = 0; j < m2; j++) {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= mod;
			}
		}
		long ans = dp[n][m1 - 1] + dp[n][m2 - 1];
		ans %= mod;
		System.out.println(ans);
	}
}
0