結果
| 問題 | No.1702 count good string |
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2021-10-08 22:15:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 238 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 320 ms |
| コンパイル使用メモリ | 81,972 KB |
| 実行使用メモリ | 76,460 KB |
| 最終ジャッジ日時 | 2024-07-23 04:44:33 |
| 合計ジャッジ時間 | 7,987 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
"""
"""
from sys import stdin
import sys
yuki = "yukicoder"
N = int(stdin.readline())
S = stdin.readline()[:-1]
dp = [ [0] * 2 for i in range(len(yuki)+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(N):
ndp = [ [dp[a][j] for j in range(2)] for a in range(len(yuki)+1)]
for a in range(len(yuki)):
for b in range(2):
if yuki[a] == S[i]:
ndp[a+1][b] += dp[a][b]
ndp[a+1][b] %= mod
elif b == 0 and S[i] == "?":
ndp[a+1][1] += dp[a][0]
ndp[a+1][1] %= mod
dp = ndp
ans = 0
for i in range(2):
ans += dp[-1][i]
print (ans % mod)
SPD_9X2