結果

問題 No.2419 MMA文字列2
ユーザー shobonvipshobonvip
提出日時 2023-08-12 13:43:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 78,636 KB
最終ジャッジ日時 2024-04-30 03:55:20
合計ジャッジ時間 5,217 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,196 KB
testcase_01 AC 41 ms
59,116 KB
testcase_02 AC 41 ms
58,860 KB
testcase_03 AC 44 ms
61,004 KB
testcase_04 AC 44 ms
59,804 KB
testcase_05 AC 38 ms
52,568 KB
testcase_06 AC 37 ms
52,892 KB
testcase_07 AC 41 ms
52,860 KB
testcase_08 AC 37 ms
52,524 KB
testcase_09 AC 39 ms
52,524 KB
testcase_10 AC 45 ms
59,604 KB
testcase_11 AC 44 ms
59,972 KB
testcase_12 AC 100 ms
76,444 KB
testcase_13 AC 69 ms
76,264 KB
testcase_14 AC 132 ms
76,944 KB
testcase_15 AC 105 ms
76,524 KB
testcase_16 AC 137 ms
76,792 KB
testcase_17 AC 85 ms
76,240 KB
testcase_18 AC 139 ms
76,912 KB
testcase_19 AC 141 ms
77,092 KB
testcase_20 AC 85 ms
76,200 KB
testcase_21 AC 77 ms
76,660 KB
testcase_22 AC 224 ms
78,296 KB
testcase_23 AC 223 ms
78,092 KB
testcase_24 AC 223 ms
78,176 KB
testcase_25 AC 226 ms
78,216 KB
testcase_26 AC 78 ms
76,168 KB
testcase_27 AC 223 ms
78,164 KB
testcase_28 AC 225 ms
78,172 KB
testcase_29 AC 225 ms
78,092 KB
testcase_30 AC 223 ms
78,368 KB
testcase_31 AC 231 ms
78,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()[::-1]
n = len(s)
a = [ord(s[i]) - ord("A") for i in range(n)]
dp = [[0] * 26 for i in range(2)]
ans = 0
for i in range(n):
	ndp = [[0] * 26 for i in range(2)]
	for j in range(2):
		for k in range(26):
			ndp[j][k] = dp[j][k]
	ndp[0][a[i]] += 1
	for j in range(26):
		if j == a[i]: continue
		ndp[1][a[i]] += dp[0][j]
	ans += dp[1][a[i]]
	dp[0] = ndp[0][::]
	dp[1] = ndp[1][::]

print(ans)
0