結果

問題 No.1702 count good string
ユーザー O2MTO2MT
提出日時 2021-10-08 22:55:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 348 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 184,632 KB
最終ジャッジ日時 2023-09-30 12:08:25
合計ジャッジ時間 11,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,528 KB
testcase_01 AC 74 ms
71,404 KB
testcase_02 AC 74 ms
71,540 KB
testcase_03 AC 77 ms
75,232 KB
testcase_04 AC 76 ms
75,304 KB
testcase_05 AC 77 ms
75,104 KB
testcase_06 AC 75 ms
75,108 KB
testcase_07 AC 77 ms
75,244 KB
testcase_08 AC 78 ms
75,216 KB
testcase_09 AC 76 ms
75,200 KB
testcase_10 AC 78 ms
75,216 KB
testcase_11 AC 76 ms
75,272 KB
testcase_12 AC 75 ms
75,212 KB
testcase_13 AC 345 ms
184,632 KB
testcase_14 AC 338 ms
184,248 KB
testcase_15 AC 339 ms
184,296 KB
testcase_16 AC 336 ms
184,248 KB
testcase_17 AC 348 ms
184,172 KB
testcase_18 AC 339 ms
184,020 KB
testcase_19 AC 337 ms
183,992 KB
testcase_20 AC 338 ms
184,268 KB
testcase_21 AC 335 ms
184,252 KB
testcase_22 AC 335 ms
184,488 KB
testcase_23 AC 87 ms
76,540 KB
testcase_24 AC 91 ms
76,692 KB
testcase_25 AC 89 ms
76,712 KB
testcase_26 AC 88 ms
76,744 KB
testcase_27 AC 88 ms
76,792 KB
testcase_28 AC 88 ms
76,732 KB
testcase_29 AC 89 ms
76,936 KB
testcase_30 AC 89 ms
76,640 KB
testcase_31 AC 89 ms
76,876 KB
testcase_32 AC 88 ms
76,748 KB
testcase_33 AC 335 ms
184,000 KB
testcase_34 AC 334 ms
184,236 KB
testcase_35 AC 338 ms
184,192 KB
testcase_36 AC 340 ms
184,328 KB
testcase_37 AC 342 ms
184,216 KB
testcase_38 AC 340 ms
184,252 KB
testcase_39 AC 338 ms
184,108 KB
testcase_40 AC 339 ms
184,296 KB
testcase_41 AC 341 ms
184,332 KB
testcase_42 AC 340 ms
184,220 KB
testcase_43 AC 331 ms
184,240 KB
testcase_44 AC 347 ms
184,292 KB
testcase_45 AC 72 ms
71,380 KB
testcase_46 AC 74 ms
71,456 KB
testcase_47 AC 73 ms
71,532 KB
testcase_48 AC 74 ms
71,444 KB
testcase_49 AC 75 ms
71,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(str(input()))
MOD = 10**9+7
alp = list(' yukicoder')
M = len(alp)
dp = [[[0,0] for _ in range(11)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
  s = S[i-1]
  for j in range(M):
    dp[i][j][0] = dp[i-1][j][0]
    dp[i][j][1] = dp[i-1][j][1]
  if s != '?':
    l = -1
    for k in range(M):
      if s == alp[k]:
        l = k
        break
    if l == -1:
      continue
    dp[i][l][0] += dp[i-1][l-1][0]
    dp[i][l][0] %= MOD
    dp[i][l][1] += dp[i-1][l-1][1]
    dp[i][l][1] %= MOD
  else:
    for m in range(1,M):
      dp[i][m][1] += dp[i-1][m-1][0]
      dp[i][m][1] %= MOD

print((dp[N][M-1][0]+dp[N][M-1][1])%MOD)
0