結果

問題 No.1702 count good string
ユーザー roarisroaris
提出日時 2021-10-17 20:04:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 470 ms / 2,000 ms
コード長 596 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 199,828 KB
最終ジャッジ日時 2023-10-17 22:32:45
合計ジャッジ時間 11,853 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,472 KB
testcase_01 AC 39 ms
53,472 KB
testcase_02 AC 42 ms
59,476 KB
testcase_03 AC 52 ms
63,848 KB
testcase_04 AC 47 ms
61,772 KB
testcase_05 AC 47 ms
61,772 KB
testcase_06 AC 48 ms
61,772 KB
testcase_07 AC 47 ms
61,772 KB
testcase_08 AC 48 ms
61,772 KB
testcase_09 AC 48 ms
61,772 KB
testcase_10 AC 48 ms
61,772 KB
testcase_11 AC 51 ms
63,848 KB
testcase_12 AC 48 ms
61,772 KB
testcase_13 AC 402 ms
198,924 KB
testcase_14 AC 399 ms
198,924 KB
testcase_15 AC 398 ms
198,924 KB
testcase_16 AC 398 ms
198,636 KB
testcase_17 AC 396 ms
198,916 KB
testcase_18 AC 397 ms
198,924 KB
testcase_19 AC 458 ms
199,828 KB
testcase_20 AC 393 ms
198,916 KB
testcase_21 AC 394 ms
198,916 KB
testcase_22 AC 470 ms
199,828 KB
testcase_23 AC 60 ms
72,220 KB
testcase_24 AC 60 ms
72,224 KB
testcase_25 AC 60 ms
72,244 KB
testcase_26 AC 60 ms
72,228 KB
testcase_27 AC 69 ms
75,332 KB
testcase_28 AC 60 ms
72,248 KB
testcase_29 AC 59 ms
72,216 KB
testcase_30 AC 60 ms
72,260 KB
testcase_31 AC 61 ms
72,232 KB
testcase_32 AC 60 ms
72,244 KB
testcase_33 AC 389 ms
198,924 KB
testcase_34 AC 388 ms
198,924 KB
testcase_35 AC 390 ms
198,924 KB
testcase_36 AC 390 ms
198,924 KB
testcase_37 AC 404 ms
198,924 KB
testcase_38 AC 390 ms
198,924 KB
testcase_39 AC 392 ms
198,924 KB
testcase_40 AC 393 ms
198,924 KB
testcase_41 AC 398 ms
198,992 KB
testcase_42 AC 394 ms
198,924 KB
testcase_43 AC 377 ms
195,944 KB
testcase_44 AC 381 ms
199,328 KB
testcase_45 AC 40 ms
53,472 KB
testcase_46 AC 39 ms
53,472 KB
testcase_47 AC 40 ms
53,472 KB
testcase_48 AC 39 ms
53,472 KB
testcase_49 AC 39 ms
53,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def f(T):
    dp = [[0]*N for _ in range(len(T))]
    
    for i in range(N):
        if S[i]==T[0]:
            dp[0][i] = 1
    
    for i in range(1, len(T)):
        acc = [0]
        
        for j in range(N):
            acc.append((acc[-1]+dp[i-1][j])%MOD)
        
        for j in range(N):
            if S[j]==T[i]:
                dp[i][j] = acc[j]
    
    return sum(dp[-1])%MOD
    
N = int(input())
S = input()[:-1]
MOD = 10**9+7
T = 'yukicoder'
ans = f(T)

for i in range(len(T)):
    ans += f(T[:i]+'?'+T[i+1:])
    ans %= MOD

print(ans)
0