結果

問題 No.1702 count good string
ユーザー mkawa2mkawa2
提出日時 2021-10-08 22:16:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,160 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 77,388 KB
最終ジャッジ日時 2023-09-30 10:38:05
合計ジャッジ時間 8,962 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,768 KB
testcase_01 AC 95 ms
71,708 KB
testcase_02 AC 96 ms
71,832 KB
testcase_03 AC 95 ms
71,696 KB
testcase_04 AC 95 ms
71,832 KB
testcase_05 AC 96 ms
71,680 KB
testcase_06 AC 95 ms
71,776 KB
testcase_07 AC 95 ms
71,668 KB
testcase_08 AC 95 ms
71,596 KB
testcase_09 AC 94 ms
71,504 KB
testcase_10 AC 95 ms
71,292 KB
testcase_11 AC 96 ms
71,748 KB
testcase_12 AC 95 ms
71,712 KB
testcase_13 AC 180 ms
77,336 KB
testcase_14 AC 186 ms
77,344 KB
testcase_15 AC 187 ms
77,288 KB
testcase_16 AC 184 ms
77,260 KB
testcase_17 AC 193 ms
77,324 KB
testcase_18 AC 185 ms
77,016 KB
testcase_19 AC 191 ms
77,004 KB
testcase_20 AC 179 ms
77,028 KB
testcase_21 AC 186 ms
77,320 KB
testcase_22 AC 187 ms
77,200 KB
testcase_23 AC 104 ms
77,136 KB
testcase_24 AC 103 ms
77,076 KB
testcase_25 AC 105 ms
76,936 KB
testcase_26 AC 103 ms
76,932 KB
testcase_27 AC 104 ms
77,012 KB
testcase_28 AC 104 ms
76,884 KB
testcase_29 AC 105 ms
76,988 KB
testcase_30 AC 104 ms
77,088 KB
testcase_31 AC 103 ms
77,176 KB
testcase_32 AC 102 ms
77,060 KB
testcase_33 AC 166 ms
77,140 KB
testcase_34 AC 170 ms
76,948 KB
testcase_35 AC 164 ms
77,388 KB
testcase_36 AC 164 ms
77,228 KB
testcase_37 AC 170 ms
77,212 KB
testcase_38 AC 166 ms
77,212 KB
testcase_39 AC 160 ms
77,108 KB
testcase_40 AC 162 ms
77,132 KB
testcase_41 AC 168 ms
77,128 KB
testcase_42 AC 167 ms
77,220 KB
testcase_43 AC 168 ms
77,100 KB
testcase_44 AC 179 ms
77,288 KB
testcase_45 AC 95 ms
71,468 KB
testcase_46 AC 94 ms
71,580 KB
testcase_47 AC 94 ms
71,288 KB
testcase_48 AC 94 ms
71,752 KB
testcase_49 AC 94 ms
71,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**19
# md = 998244353
md = 10**9+7

from collections import defaultdict

n = II()
s = SI()

def cnt(s, t):
    n = len(t)
    dp = [0]*(n+1)
    ctoi = defaultdict(list)
    for i, c in enumerate(t):
        ctoi[c].append(i)

    dp[0] = 1
    for c in s:
        for i in ctoi[c][::-1]:
            dp[i+1] += dp[i]
            dp[i+1] %= md

    return dp[-1]

t = "yukicoder"
tt = [t]
for i in range(len(t)):
    nt = t[:i]+"?"+t[i+1:]
    tt.append(nt)
# print(tt)

ans = 0
for t in tt:
    ans += cnt(s, t)
    ans %= md

print(ans)
0