結果

問題 No.2419 MMA文字列2
ユーザー ntudantuda
提出日時 2023-08-13 19:24:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 95,852 KB
最終ジャッジ日時 2024-05-01 11:25:49
合計ジャッジ時間 3,065 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,328 KB
testcase_01 AC 41 ms
53,816 KB
testcase_02 AC 41 ms
55,328 KB
testcase_03 AC 42 ms
54,244 KB
testcase_04 AC 40 ms
54,376 KB
testcase_05 AC 40 ms
55,476 KB
testcase_06 AC 40 ms
54,608 KB
testcase_07 AC 40 ms
55,196 KB
testcase_08 AC 40 ms
53,724 KB
testcase_09 AC 39 ms
53,880 KB
testcase_10 AC 43 ms
54,852 KB
testcase_11 AC 40 ms
54,552 KB
testcase_12 AC 53 ms
68,792 KB
testcase_13 AC 48 ms
61,840 KB
testcase_14 AC 56 ms
74,696 KB
testcase_15 AC 53 ms
69,792 KB
testcase_16 AC 58 ms
75,568 KB
testcase_17 AC 48 ms
65,028 KB
testcase_18 AC 68 ms
81,004 KB
testcase_19 AC 67 ms
80,844 KB
testcase_20 AC 51 ms
66,360 KB
testcase_21 AC 48 ms
64,548 KB
testcase_22 AC 82 ms
91,368 KB
testcase_23 AC 82 ms
91,556 KB
testcase_24 AC 82 ms
95,852 KB
testcase_25 AC 83 ms
95,724 KB
testcase_26 AC 48 ms
64,228 KB
testcase_27 AC 66 ms
87,140 KB
testcase_28 AC 77 ms
85,776 KB
testcase_29 AC 78 ms
85,924 KB
testcase_30 AC 78 ms
85,976 KB
testcase_31 AC 77 ms
85,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

dic = defaultdict(list)
S = list(input())
for i, s in enumerate(S, start=1):
    dic[s].append(i)
N = len(S)
ans = 0
for k, V in dic.items():
    n = len(V)
    for j, v in enumerate(V, start=1):
        if j > 1:
            ans += (j - 1) * (N - v - n + j)
print(ans)
0