結果

問題 No.1702 count good string
ユーザー MasKoaTSMasKoaTS
提出日時 2021-10-31 18:04:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 407 ms / 2,000 ms
コード長 1,203 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 159,488 KB
最終ジャッジ日時 2024-04-17 11:40:04
合計ジャッジ時間 14,746 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
86,400 KB
testcase_01 AC 132 ms
86,144 KB
testcase_02 AC 132 ms
86,912 KB
testcase_03 AC 145 ms
89,692 KB
testcase_04 AC 145 ms
89,252 KB
testcase_05 AC 141 ms
89,472 KB
testcase_06 AC 144 ms
89,472 KB
testcase_07 AC 142 ms
89,472 KB
testcase_08 AC 144 ms
89,484 KB
testcase_09 AC 144 ms
89,472 KB
testcase_10 AC 145 ms
89,324 KB
testcase_11 AC 144 ms
89,336 KB
testcase_12 AC 144 ms
89,216 KB
testcase_13 AC 390 ms
159,084 KB
testcase_14 AC 388 ms
159,104 KB
testcase_15 AC 402 ms
159,112 KB
testcase_16 AC 387 ms
159,172 KB
testcase_17 AC 391 ms
158,976 KB
testcase_18 AC 403 ms
159,188 KB
testcase_19 AC 388 ms
159,232 KB
testcase_20 AC 387 ms
159,104 KB
testcase_21 AC 392 ms
159,232 KB
testcase_22 AC 407 ms
159,312 KB
testcase_23 AC 148 ms
89,600 KB
testcase_24 AC 148 ms
89,472 KB
testcase_25 AC 145 ms
89,708 KB
testcase_26 AC 148 ms
89,552 KB
testcase_27 AC 147 ms
89,532 KB
testcase_28 AC 147 ms
89,520 KB
testcase_29 AC 146 ms
89,856 KB
testcase_30 AC 147 ms
89,728 KB
testcase_31 AC 147 ms
89,216 KB
testcase_32 AC 148 ms
89,216 KB
testcase_33 AC 388 ms
159,488 KB
testcase_34 AC 377 ms
159,104 KB
testcase_35 AC 377 ms
159,232 KB
testcase_36 AC 375 ms
159,232 KB
testcase_37 AC 378 ms
159,104 KB
testcase_38 AC 376 ms
159,232 KB
testcase_39 AC 375 ms
159,104 KB
testcase_40 AC 381 ms
159,104 KB
testcase_41 AC 376 ms
159,232 KB
testcase_42 AC 376 ms
159,104 KB
testcase_43 AC 383 ms
159,400 KB
testcase_44 AC 383 ms
158,848 KB
testcase_45 AC 130 ms
86,088 KB
testcase_46 AC 131 ms
86,180 KB
testcase_47 AC 132 ms
86,188 KB
testcase_48 AC 129 ms
86,528 KB
testcase_49 AC 129 ms
86,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from copy import deepcopy as dcopy
import math
import sys
sys.setrecursionlimit(10**6)
def input():
    return sys.stdin.readline().rstrip()
def getN():
	return int(sys.stdin.readline().rstrip())
def getNs():
	return map(int,sys.stdin.readline().rstrip().split())
def getList():
	return list(map(int,sys.stdin.readline().rstrip().split()))
def strinps(n):
	return [sys.stdin.readline().rstrip() for _ in range(n)]
pi = 3.141592653589793
mod = 10**9+7
MOD = 998244353
INF = math.inf
dx = [1,0,-1,0];	dy = [0,1,0,-1]


"""
Main Code
"""

n = getN()
s = input()
words = ["yukicoder","?ukicoder","y?kicoder","yu?icoder","yuk?coder","yuki?oder","yukic?der","yukico?er","yukicod?r","yukicode?"]

def calc_dp(w):
	dp = [[0]*n for _ in range(9)]
	if(s[0] == w[0]):
		dp[0][0] = 1
	for i in range(1,n):
		if(s[i] == w[0]):
			dp[0][i] = (dp[0][i-1] + 1) % mod
		else:
			dp[0][i] = dp[0][i-1]
		for j in range(1,9):
			if(s[i] == w[j]):
				dp[j][i] = (dp[j][i-1] + dp[j-1][i-1]) % mod
			else:
				dp[j][i] = dp[j][i-1]
	return dp[8][n-1]

print(sum(calc_dp(w) for w in words) % mod)
0