結果

問題 No.2419 MMA文字列2
ユーザー ohanaohana
提出日時 2023-11-06 17:37:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 234 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 76,060 KB
最終ジャッジ日時 2023-11-06 17:37:32
合計ジャッジ時間 4,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,596 KB
testcase_01 AC 38 ms
53,596 KB
testcase_02 AC 38 ms
53,596 KB
testcase_03 AC 40 ms
53,596 KB
testcase_04 AC 39 ms
53,596 KB
testcase_05 AC 38 ms
53,596 KB
testcase_06 AC 39 ms
53,596 KB
testcase_07 AC 38 ms
53,596 KB
testcase_08 AC 38 ms
53,596 KB
testcase_09 AC 39 ms
53,596 KB
testcase_10 AC 41 ms
53,596 KB
testcase_11 AC 38 ms
53,596 KB
testcase_12 AC 50 ms
64,204 KB
testcase_13 AC 45 ms
62,156 KB
testcase_14 AC 57 ms
68,300 KB
testcase_15 AC 51 ms
66,252 KB
testcase_16 AC 56 ms
68,300 KB
testcase_17 AC 49 ms
64,204 KB
testcase_18 AC 58 ms
68,300 KB
testcase_19 AC 59 ms
70,348 KB
testcase_20 AC 51 ms
64,204 KB
testcase_21 AC 47 ms
62,156 KB
testcase_22 AC 75 ms
76,056 KB
testcase_23 AC 74 ms
76,056 KB
testcase_24 AC 75 ms
76,056 KB
testcase_25 AC 74 ms
76,056 KB
testcase_26 AC 45 ms
62,028 KB
testcase_27 AC 62 ms
64,464 KB
testcase_28 AC 78 ms
76,060 KB
testcase_29 AC 74 ms
76,056 KB
testcase_30 AC 76 ms
76,060 KB
testcase_31 AC 80 ms
76,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

s = input()

ans = 0
t = 0
dd = defaultdict(int)
for c in s:
    k = 0
    dd[c] += 1
    if 2 <= dd[c]:
        t += dd[c] - 1
        k = (dd[c] * (dd[c] - 1)) // 2
    ans += t - k


print(ans)
0