結果

問題 No.2419 MMA文字列2
ユーザー chaemonchaemon
提出日時 2023-08-15 15:40:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 547 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 10,532 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-15 15:40:52
合計ジャッジ時間 30,546 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,936 KB
testcase_01 AC 16 ms
7,688 KB
testcase_02 AC 15 ms
7,684 KB
testcase_03 AC 16 ms
7,896 KB
testcase_04 AC 15 ms
7,748 KB
testcase_05 AC 15 ms
7,772 KB
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 15 ms
7,688 KB
testcase_08 AC 15 ms
7,864 KB
testcase_09 AC 16 ms
7,740 KB
testcase_10 AC 16 ms
7,804 KB
testcase_11 AC 16 ms
7,748 KB
testcase_12 AC 616 ms
7,976 KB
testcase_13 AC 104 ms
7,840 KB
testcase_14 AC 1,152 ms
7,996 KB
testcase_15 AC 674 ms
7,956 KB
testcase_16 AC 1,200 ms
7,948 KB
testcase_17 AC 353 ms
7,872 KB
testcase_18 AC 1,239 ms
8,028 KB
testcase_19 AC 1,324 ms
8,032 KB
testcase_20 AC 409 ms
8,004 KB
testcase_21 AC 290 ms
7,832 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 306 ms
7,844 KB
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
権限があれば一括ダウンロードができます

ソースコード

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