結果

問題 No.2419 MMA文字列2
ユーザー lloyzlloyz
提出日時 2023-08-23 00:46:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 141,140 KB
最終ジャッジ日時 2023-08-23 00:46:21
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,128 KB
testcase_01 AC 73 ms
70,988 KB
testcase_02 AC 74 ms
71,328 KB
testcase_03 AC 80 ms
76,380 KB
testcase_04 AC 78 ms
76,244 KB
testcase_05 AC 73 ms
71,040 KB
testcase_06 AC 76 ms
71,000 KB
testcase_07 AC 73 ms
71,164 KB
testcase_08 AC 75 ms
71,348 KB
testcase_09 AC 77 ms
71,400 KB
testcase_10 AC 78 ms
71,008 KB
testcase_11 AC 83 ms
75,772 KB
testcase_12 AC 140 ms
90,172 KB
testcase_13 AC 97 ms
76,316 KB
testcase_14 AC 185 ms
104,616 KB
testcase_15 AC 143 ms
90,376 KB
testcase_16 AC 193 ms
105,632 KB
testcase_17 AC 145 ms
82,048 KB
testcase_18 AC 189 ms
106,364 KB
testcase_19 AC 193 ms
106,536 KB
testcase_20 AC 120 ms
82,204 KB
testcase_21 AC 112 ms
81,804 KB
testcase_22 AC 300 ms
140,940 KB
testcase_23 AC 336 ms
141,140 KB
testcase_24 AC 296 ms
140,996 KB
testcase_25 AC 303 ms
141,060 KB
testcase_26 AC 114 ms
81,860 KB
testcase_27 AC 313 ms
141,052 KB
testcase_28 AC 300 ms
141,008 KB
testcase_29 AC 298 ms
141,004 KB
testcase_30 AC 296 ms
140,764 KB
testcase_31 AC 324 ms
141,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = list(input())

n = len(S)
DP = [[0 for _ in range(26)] for _ in range(n + 1)]
ans = 0
for i in range(n):
    idx = ord(S[i]) - ord('A')
    for j in range(26):
        if j == idx:
            DP[i + 1][j] = DP[i][j] + 1
        else:
            DP[i + 1][j] = DP[i][j]
    for j in range(26):
        if j == idx:
            continue
        ans += DP[i][j] * (DP[i][j] - 1) // 2
print(ans)
0