結果

問題 No.2419 MMA文字列2
ユーザー kemunikukemuniku
提出日時 2023-08-12 13:48:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 89,216 KB
最終ジャッジ日時 2024-04-30 04:10:16
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,632 KB
testcase_01 AC 43 ms
53,504 KB
testcase_02 AC 43 ms
53,632 KB
testcase_03 AC 46 ms
53,632 KB
testcase_04 AC 44 ms
53,632 KB
testcase_05 AC 44 ms
53,504 KB
testcase_06 AC 50 ms
53,760 KB
testcase_07 AC 42 ms
53,504 KB
testcase_08 AC 44 ms
54,016 KB
testcase_09 AC 43 ms
54,016 KB
testcase_10 AC 42 ms
54,016 KB
testcase_11 AC 46 ms
53,888 KB
testcase_12 AC 82 ms
76,416 KB
testcase_13 AC 67 ms
72,832 KB
testcase_14 AC 99 ms
76,928 KB
testcase_15 AC 100 ms
76,416 KB
testcase_16 AC 100 ms
76,928 KB
testcase_17 AC 76 ms
76,616 KB
testcase_18 AC 102 ms
77,024 KB
testcase_19 AC 102 ms
77,176 KB
testcase_20 AC 78 ms
76,416 KB
testcase_21 AC 77 ms
76,288 KB
testcase_22 AC 151 ms
85,376 KB
testcase_23 AC 146 ms
85,204 KB
testcase_24 AC 152 ms
87,808 KB
testcase_25 AC 150 ms
87,844 KB
testcase_26 AC 76 ms
76,756 KB
testcase_27 AC 152 ms
89,216 KB
testcase_28 AC 144 ms
78,848 KB
testcase_29 AC 145 ms
78,940 KB
testcase_30 AC 144 ms
78,848 KB
testcase_31 AC 144 ms
78,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
from collections import defaultdict
d = defaultdict(list)
ans = 0
N = len(S)
for i in range(len(S)):
  d[S[i]].append(i)
import bisect
for i in range(len(S)):
  x = bisect.bisect_left(d[S[i]],i)
  ans += x*(N-(i+1)-(len(d[S[i]])-(x+1)))
print(ans)
0