結果

問題 No.1702 count good string
ユーザー puznekopuzneko
提出日時 2021-10-29 23:48:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 106,752 KB
最終ジャッジ日時 2024-04-16 16:01:40
合計ジャッジ時間 7,323 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 39 ms
51,968 KB
testcase_02 AC 39 ms
52,608 KB
testcase_03 AC 40 ms
52,352 KB
testcase_04 AC 40 ms
52,480 KB
testcase_05 AC 40 ms
52,992 KB
testcase_06 AC 39 ms
52,736 KB
testcase_07 AC 39 ms
52,992 KB
testcase_08 AC 38 ms
52,992 KB
testcase_09 AC 39 ms
52,992 KB
testcase_10 AC 40 ms
52,992 KB
testcase_11 AC 39 ms
52,736 KB
testcase_12 AC 41 ms
52,480 KB
testcase_13 AC 180 ms
106,496 KB
testcase_14 AC 173 ms
106,580 KB
testcase_15 AC 166 ms
106,240 KB
testcase_16 AC 177 ms
106,240 KB
testcase_17 AC 174 ms
106,628 KB
testcase_18 AC 171 ms
106,348 KB
testcase_19 AC 166 ms
106,724 KB
testcase_20 AC 176 ms
106,264 KB
testcase_21 AC 176 ms
106,496 KB
testcase_22 AC 176 ms
106,624 KB
testcase_23 AC 55 ms
65,408 KB
testcase_24 AC 54 ms
65,664 KB
testcase_25 AC 52 ms
65,152 KB
testcase_26 AC 53 ms
65,152 KB
testcase_27 AC 55 ms
65,536 KB
testcase_28 AC 55 ms
65,024 KB
testcase_29 AC 54 ms
65,408 KB
testcase_30 AC 53 ms
65,536 KB
testcase_31 AC 54 ms
65,536 KB
testcase_32 AC 55 ms
65,536 KB
testcase_33 AC 167 ms
106,300 KB
testcase_34 AC 175 ms
106,624 KB
testcase_35 AC 178 ms
106,240 KB
testcase_36 AC 175 ms
106,420 KB
testcase_37 AC 175 ms
106,496 KB
testcase_38 AC 174 ms
106,496 KB
testcase_39 AC 174 ms
106,416 KB
testcase_40 AC 176 ms
106,184 KB
testcase_41 AC 175 ms
106,240 KB
testcase_42 AC 176 ms
106,368 KB
testcase_43 AC 164 ms
106,496 KB
testcase_44 AC 170 ms
106,752 KB
testcase_45 AC 38 ms
52,096 KB
testcase_46 AC 39 ms
52,224 KB
testcase_47 AC 38 ms
52,224 KB
testcase_48 AC 37 ms
51,968 KB
testcase_49 AC 36 ms
51,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
d = {"y":1,"u":2,"k":3,"i":4,"c":5,"o":6,"d":7,"e":8,"r":9,"?":-1}
p = 10**9+7

dp1 = [[0 for i in range(10)] for j in range(n+1)]
dp2 = [[0 for i in range(10)] for j in range(n+1)]
dp1[0][0] = 1
for i in range(n):
    for j in range(10):
        dp1[i+1][j] = dp1[i][j]
        dp2[i+1][j] = dp2[i][j]
    if s[i] == "?":
        for j in range(1,10):
            dp2[i+1][j] = (dp2[i+1][j] + dp1[i][j-1]) % p
    elif s[i] in d:
        ind = d[s[i]]
        dp1[i+1][ind] = (dp1[i+1][ind] + dp1[i][ind-1]) % p
        dp2[i+1][ind] = (dp2[i+1][ind] + dp2[i][ind-1]) % p

ans = (dp1[n][9] + dp2[n][9]) % p
print("{}".format(ans))
0