結果

問題 No.2419 MMA文字列2
ユーザー Basin-BugBasin-Bug
提出日時 2023-08-12 14:52:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 290 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 89,280 KB
最終ジャッジ日時 2024-04-30 07:24:31
合計ジャッジ時間 2,923 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,024 KB
testcase_01 AC 40 ms
53,696 KB
testcase_02 AC 40 ms
54,660 KB
testcase_03 AC 40 ms
55,240 KB
testcase_04 AC 40 ms
53,756 KB
testcase_05 AC 39 ms
54,100 KB
testcase_06 AC 40 ms
53,632 KB
testcase_07 AC 40 ms
53,936 KB
testcase_08 AC 39 ms
54,024 KB
testcase_09 AC 40 ms
55,080 KB
testcase_10 AC 39 ms
54,420 KB
testcase_11 AC 41 ms
53,808 KB
testcase_12 AC 51 ms
67,540 KB
testcase_13 AC 48 ms
62,932 KB
testcase_14 AC 55 ms
73,852 KB
testcase_15 AC 52 ms
69,004 KB
testcase_16 AC 55 ms
73,252 KB
testcase_17 AC 49 ms
64,908 KB
testcase_18 AC 55 ms
73,984 KB
testcase_19 AC 56 ms
74,080 KB
testcase_20 AC 49 ms
65,232 KB
testcase_21 AC 49 ms
64,740 KB
testcase_22 AC 72 ms
84,824 KB
testcase_23 AC 73 ms
84,840 KB
testcase_24 AC 73 ms
87,960 KB
testcase_25 AC 75 ms
88,108 KB
testcase_26 AC 50 ms
65,192 KB
testcase_27 AC 75 ms
89,280 KB
testcase_28 AC 69 ms
76,980 KB
testcase_29 AC 67 ms
76,904 KB
testcase_30 AC 69 ms
76,704 KB
testcase_31 AC 70 ms
76,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
S  = str(input())
dis = defaultdict(list)
for i in range(len(S)):
  dis[S[i]].append(i + 1)

ans = 0
for i in dis.keys():
  if len(dis[i]) >= 2:
    for j in range(1, len(dis[i])):
      ans += (len(S) - dis[i][j] - (len(dis[i]) - j - 1)) * j

print(ans)
0