結果

問題 No.1702 count good string
ユーザー lloyzlloyz
提出日時 2021-11-14 16:01:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 451 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 176,976 KB
最終ジャッジ日時 2023-08-19 22:56:22
合計ジャッジ時間 15,140 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,392 KB
testcase_01 AC 82 ms
71,640 KB
testcase_02 AC 79 ms
71,596 KB
testcase_03 AC 94 ms
77,524 KB
testcase_04 AC 106 ms
77,476 KB
testcase_05 AC 92 ms
77,700 KB
testcase_06 AC 92 ms
77,476 KB
testcase_07 AC 94 ms
77,620 KB
testcase_08 AC 93 ms
77,212 KB
testcase_09 AC 93 ms
77,580 KB
testcase_10 AC 96 ms
77,420 KB
testcase_11 AC 96 ms
77,472 KB
testcase_12 AC 93 ms
77,508 KB
testcase_13 AC 436 ms
176,756 KB
testcase_14 AC 440 ms
176,756 KB
testcase_15 AC 439 ms
176,584 KB
testcase_16 AC 444 ms
176,732 KB
testcase_17 AC 434 ms
176,976 KB
testcase_18 AC 424 ms
176,648 KB
testcase_19 AC 431 ms
176,416 KB
testcase_20 AC 440 ms
176,796 KB
testcase_21 AC 440 ms
176,868 KB
testcase_22 AC 431 ms
176,972 KB
testcase_23 AC 108 ms
77,860 KB
testcase_24 AC 110 ms
77,928 KB
testcase_25 AC 104 ms
77,684 KB
testcase_26 AC 108 ms
77,680 KB
testcase_27 AC 114 ms
77,696 KB
testcase_28 AC 106 ms
77,612 KB
testcase_29 AC 111 ms
77,708 KB
testcase_30 AC 108 ms
77,736 KB
testcase_31 AC 106 ms
77,720 KB
testcase_32 AC 107 ms
77,756 KB
testcase_33 AC 446 ms
176,640 KB
testcase_34 AC 443 ms
176,376 KB
testcase_35 AC 450 ms
176,644 KB
testcase_36 AC 422 ms
176,692 KB
testcase_37 AC 439 ms
176,652 KB
testcase_38 AC 433 ms
176,736 KB
testcase_39 AC 430 ms
176,668 KB
testcase_40 AC 445 ms
176,552 KB
testcase_41 AC 442 ms
176,652 KB
testcase_42 AC 451 ms
176,728 KB
testcase_43 AC 424 ms
176,588 KB
testcase_44 AC 432 ms
176,660 KB
testcase_45 AC 84 ms
71,504 KB
testcase_46 AC 81 ms
71,668 KB
testcase_47 AC 83 ms
71,380 KB
testcase_48 AC 86 ms
71,428 KB
testcase_49 AC 84 ms
71,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n = int(input())
S = list(input())

yukicoder = defaultdict(int)
yukicoder_str = "yukicoder"
for i in range(9):
    yukicoder[yukicoder_str[i]] = i

dp = [[[0 for _ in range(2)] for _ in range(10)] for _ in range(n + 1)]
dp[0][0][0] = 1
mod = 10**9 + 7
for i in range(n):
    for j in range(10):
        for k in range(2):
            dp[i + 1][j][k] += dp[i][j][k]
    if S[i] in yukicoder_str:
        for k in range(2):
            dp[i + 1][yukicoder[S[i]] + 1][k] += dp[i][yukicoder[S[i]]][k]
            dp[i + 1][yukicoder[S[i]] + 1][k] %= mod
    elif S[i] == '?':
        for j in range(9):
            dp[i + 1][j + 1][1] += dp[i][j][0]
            dp[i + 1][j + 1][1] %= mod
print(sum(dp[-1][-1]) % mod)

0