結果

問題 No.2419 MMA文字列2
ユーザー chaemonchaemon
提出日時 2023-08-15 15:33:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 912 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 117,648 KB
最終ジャッジ日時 2023-08-15 15:33:34
合計ジャッジ時間 15,342 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,232 KB
testcase_01 AC 15 ms
7,928 KB
testcase_02 AC 15 ms
7,944 KB
testcase_03 AC 15 ms
7,832 KB
testcase_04 AC 14 ms
7,928 KB
testcase_05 AC 14 ms
7,936 KB
testcase_06 AC 13 ms
7,752 KB
testcase_07 AC 14 ms
7,772 KB
testcase_08 AC 14 ms
7,900 KB
testcase_09 AC 13 ms
7,736 KB
testcase_10 AC 14 ms
7,940 KB
testcase_11 AC 15 ms
7,952 KB
testcase_12 AC 865 ms
53,840 KB
testcase_13 AC 127 ms
10,492 KB
testcase_14 AC 1,553 ms
100,560 KB
testcase_15 AC 953 ms
62,820 KB
testcase_16 AC 1,593 ms
105,352 KB
testcase_17 AC 471 ms
32,968 KB
testcase_18 AC 1,731 ms
109,940 KB
testcase_19 AC 1,707 ms
113,268 KB
testcase_20 AC 585 ms
37,120 KB
testcase_21 AC 377 ms
26,484 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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