結果

問題 No.2419 MMA文字列2
ユーザー sepa38sepa38
提出日時 2023-07-15 14:12:07
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 378 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 587,088 KB
最終ジャッジ日時 2023-10-16 23:18:35
合計ジャッジ時間 26,580 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,564 KB
testcase_01 AC 40 ms
59,940 KB
testcase_02 AC 41 ms
59,940 KB
testcase_03 AC 45 ms
62,204 KB
testcase_04 AC 42 ms
62,060 KB
testcase_05 AC 36 ms
53,564 KB
testcase_06 AC 41 ms
59,540 KB
testcase_07 AC 35 ms
53,564 KB
testcase_08 AC 40 ms
59,540 KB
testcase_09 AC 36 ms
53,564 KB
testcase_10 AC 43 ms
59,944 KB
testcase_11 AC 42 ms
62,060 KB
testcase_12 AC 331 ms
190,064 KB
testcase_13 AC 90 ms
86,172 KB
testcase_14 AC 695 ms
295,556 KB
testcase_15 AC 370 ms
210,484 KB
testcase_16 AC 722 ms
306,252 KB
testcase_17 AC 217 ms
144,120 KB
testcase_18 AC 749 ms
316,368 KB
testcase_19 AC 765 ms
323,468 KB
testcase_20 AC 241 ms
153,376 KB
testcase_21 AC 187 ms
130,144 KB
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 AC 198 ms
137,164 KB
testcase_27 MLE -
testcase_28 MLE -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(map(lambda c: ord(c)-65, input()))
n = len(s)
dp = [[[0, 0, 0] for _ in range(26)] for _ in range(n+1)]
for i in range(n):
  c = s[i]
  for j in range(26):
    for k in range(3):
      dp[i+1][j][k] += dp[i][j][k]
    dp[i+1][c][2] += dp[i][j][1] * (c != j)
  dp[i+1][c][0] += 1
  dp[i+1][c][1] += dp[i][c][0]
ans = 0
for i in range(26):
  ans += dp[n][i][2]
print(ans)
0