結果

問題 No.1702 count good string
コンテスト
ユーザー tnodino
提出日時 2022-05-25 18:20:26
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 558 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 111 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 112,112 KB
最終ジャッジ日時 2026-04-09 01:11:05
合計ジャッジ時間 4,590 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

mod = 10**9+7
N = int(input())
S = input()
T = 'yukicoder'
DP1 = [[0] * 10 for _ in range(N+1)]
DP2 = [[0] * 10 for _ in range(N+1)]
DP1[0][0] = 1
for i in range(N):
    for j in range(9):
        if S[i] == T[j]:
            DP1[i+1][j+1] += DP1[i][j]
            DP2[i+1][j+1] += DP2[i][j]
    if S[i] == '?':
        for j in range(9):
            DP2[i+1][j+1] += DP1[i][j]
    for j in range(10):
        DP1[i+1][j] += DP1[i][j]
        DP2[i+1][j] += DP2[i][j]
        DP1[i+1][j] %= mod
        DP2[i+1][j] %= mod
print((DP1[N][9] + DP2[N][9]) % mod)
0