結果
問題 | No.2419 MMA文字列2 |
ユーザー |
![]() |
提出日時 | 2023-08-18 21:29:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 72,448 KB |
最終ジャッジ日時 | 2024-11-28 05:43:35 |
合計ジャッジ時間 | 2,937 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
# alphabet countsリストを作るか# そのときのアルファベットのコンボ数を引いた数をansに加算alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'dic = {}for i in range(26):dic[alphabets[i]] = ialphabet_counts = [0]*26combo_sum = 0S = input()N = len(S)ans = 0for i in range(N):s = S[i]old = alphabet_counts[dic[s]]alphabet_counts[dic[s]] += 1combo_sum -= (old-1)*(old)//2ans += combo_sumcombo_sum += (old)*(old+1)//2#print('i', i, 'alphabet_counts', alphabet_counts)#print('combo_sum', combo_sum, 'ans', ans)print(ans)