結果

問題 No.2419 MMA文字列2
ユーザー nikoro256nikoro256
提出日時 2023-08-12 13:56:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 260 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-04-30 04:30:55
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,376 KB
testcase_01 AC 46 ms
53,760 KB
testcase_02 AC 45 ms
53,632 KB
testcase_03 AC 46 ms
53,376 KB
testcase_04 AC 45 ms
53,376 KB
testcase_05 AC 45 ms
53,760 KB
testcase_06 AC 45 ms
53,504 KB
testcase_07 AC 46 ms
53,248 KB
testcase_08 AC 46 ms
53,376 KB
testcase_09 AC 45 ms
53,376 KB
testcase_10 AC 45 ms
53,376 KB
testcase_11 AC 46 ms
53,376 KB
testcase_12 AC 77 ms
76,032 KB
testcase_13 AC 58 ms
63,488 KB
testcase_14 AC 85 ms
75,904 KB
testcase_15 AC 79 ms
75,776 KB
testcase_16 AC 87 ms
75,904 KB
testcase_17 AC 68 ms
70,528 KB
testcase_18 AC 87 ms
75,904 KB
testcase_19 AC 88 ms
76,032 KB
testcase_20 AC 68 ms
71,936 KB
testcase_21 AC 64 ms
68,608 KB
testcase_22 AC 106 ms
76,032 KB
testcase_23 AC 103 ms
76,160 KB
testcase_24 AC 104 ms
76,288 KB
testcase_25 AC 106 ms
76,032 KB
testcase_26 AC 66 ms
69,504 KB
testcase_27 AC 104 ms
76,032 KB
testcase_28 AC 107 ms
76,032 KB
testcase_29 AC 109 ms
76,160 KB
testcase_30 AC 108 ms
76,032 KB
testcase_31 AC 109 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
S=input()
all=defaultdict(int)
for i in range(len(S)):
    all[S[i]]+=1
ans=0
left=defaultdict(int)
for i in range(len(S)):
    ans_d=left[S[i]]
    left[S[i]]+=1
    ans+=ans_d*(len(S)-1-i-(all[S[i]]-left[S[i]]))
print(ans)
0