結果

問題 No.2419 MMA文字列2
ユーザー chaemonchaemon
提出日時 2023-08-15 15:43:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 394 ms / 2,000 ms
コード長 912 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 86,516 KB
実行使用メモリ 133,100 KB
最終ジャッジ日時 2023-08-15 15:43:49
合計ジャッジ時間 8,313 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,956 KB
testcase_01 AC 71 ms
70,796 KB
testcase_02 AC 71 ms
70,836 KB
testcase_03 AC 89 ms
75,804 KB
testcase_04 AC 86 ms
75,852 KB
testcase_05 AC 71 ms
71,048 KB
testcase_06 AC 71 ms
70,856 KB
testcase_07 AC 72 ms
70,852 KB
testcase_08 AC 72 ms
71,064 KB
testcase_09 AC 72 ms
71,056 KB
testcase_10 AC 73 ms
70,864 KB
testcase_11 AC 80 ms
76,220 KB
testcase_12 AC 154 ms
88,536 KB
testcase_13 AC 93 ms
76,196 KB
testcase_14 AC 223 ms
100,544 KB
testcase_15 AC 164 ms
91,776 KB
testcase_16 AC 215 ms
101,712 KB
testcase_17 AC 121 ms
80,992 KB
testcase_18 AC 226 ms
103,336 KB
testcase_19 AC 224 ms
103,332 KB
testcase_20 AC 133 ms
80,816 KB
testcase_21 AC 115 ms
80,620 KB
testcase_22 AC 371 ms
132,900 KB
testcase_23 AC 383 ms
133,100 KB
testcase_24 AC 394 ms
133,004 KB
testcase_25 AC 367 ms
132,836 KB
testcase_26 AC 117 ms
80,784 KB
testcase_27 AC 361 ms
132,892 KB
testcase_28 AC 387 ms
132,980 KB
testcase_29 AC 389 ms
132,888 KB
testcase_30 AC 376 ms
132,672 KB
testcase_31 AC 385 ms
132,984 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)] for _ in range(len(S)+1)]
for i, A in enumerate(S):
    i += 1
    #for MM in alpha_set:
    for MM in range(26):
        ruiseki[i][MM] += ruiseki[i-1][MM] 
    ruiseki[i][ord(A) - ord('A')] += 1 

ans = 0
for i in  range(len(S)):
    # S[i]をMMA文字列の3文字目のアルファベットとし、変数Aとする
    #A = S[i]
    A = ord(S[i]) - ord('A')
    # 変数MMを、MMA文字列の1文字目と2文字目のアルファベットとする
    #for MM in ruiseki[i]:
    for MM in range(26):
        if A == MM: # 1文字目2文字目3文字目が全て同じ文字列はMMA文字列でない
            continue
        ans += ruiseki[i][MM]*(ruiseki[i][MM]-1)//2

print(ans)
0