結果

問題 No.2419 MMA文字列2
ユーザー chaemonchaemon
提出日時 2023-08-15 15:41:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 86,364 KB
実行使用メモリ 76,888 KB
最終ジャッジ日時 2023-08-15 15:41:06
合計ジャッジ時間 5,198 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,768 KB
testcase_01 AC 71 ms
70,784 KB
testcase_02 AC 71 ms
71,096 KB
testcase_03 AC 76 ms
75,916 KB
testcase_04 AC 78 ms
75,996 KB
testcase_05 AC 72 ms
71,020 KB
testcase_06 AC 71 ms
70,748 KB
testcase_07 AC 69 ms
70,820 KB
testcase_08 AC 76 ms
70,688 KB
testcase_09 AC 71 ms
70,824 KB
testcase_10 AC 73 ms
70,948 KB
testcase_11 AC 77 ms
76,080 KB
testcase_12 AC 96 ms
76,004 KB
testcase_13 AC 82 ms
75,996 KB
testcase_14 AC 113 ms
75,936 KB
testcase_15 AC 102 ms
76,184 KB
testcase_16 AC 115 ms
76,004 KB
testcase_17 AC 89 ms
75,952 KB
testcase_18 AC 114 ms
76,008 KB
testcase_19 AC 120 ms
75,816 KB
testcase_20 AC 90 ms
75,852 KB
testcase_21 AC 85 ms
76,068 KB
testcase_22 AC 154 ms
76,788 KB
testcase_23 AC 161 ms
76,820 KB
testcase_24 AC 161 ms
76,888 KB
testcase_25 AC 154 ms
76,652 KB
testcase_26 AC 85 ms
75,864 KB
testcase_27 AC 165 ms
76,404 KB
testcase_28 AC 159 ms
76,736 KB
testcase_29 AC 177 ms
76,784 KB
testcase_30 AC 156 ms
76,792 KB
testcase_31 AC 159 ms
76,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
#alpha_set = set(list(S))
# ruiseki[i][s]をS[:i]のアルファベットsの出現回数とする
# 初期化
#ruiseki = [{s:0 for s in alpha_set} for _ in range(len(S)+1)]
ruiseki = [0 for _ in range(26)]
ans = 0
for i, A in enumerate(S):
    i += 1
    #for MM in alpha_set:
    for MM in range(26):
        if ord(A) - ord('A') == MM: # 1文字目2文字目3文字目が全て同じ文字列はMMA文字列でない
            continue
        ans += ruiseki[MM]*(ruiseki[MM]-1)//2
    ruiseki[ord(A) - ord('A')] += 1 

print(ans)
0