結果

問題 No.1702 count good string
ユーザー chineristAC
提出日時 2021-10-08 22:11:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,440 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-07-23 04:35:08
合計ジャッジ時間 4,934 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random
from collections import deque
from heapq import heappush,heappop

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 10**9 + 7

N = int(input())
S = input()

T = "yukicoder"

dp = [0 for i in range(2*len(T)+2)]
dp[0] = 1
for i in range(N):
    ndp = [x for x in dp]
    for j in range(len(T)):
        if S[i]==T[j]:
            ndp[2*j+2] += dp[2*j]
            ndp[2*j+2] %= mod

            ndp[2*j+3] += dp[2*j+1]
            ndp[2*j+3] %= mod
        
        elif S[i]=="?":
            ndp[2*j+3] += dp[2*j]
            ndp[2*j+3] %= mod
    
    dp = ndp

res = dp[2*len(T)] + dp[2*len(T)+1]
print(res % mod)


0