結果

問題 No.2419 MMA文字列2
ユーザー dmasuprodmasupro
提出日時 2023-08-14 20:53:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 431 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 342,792 KB
最終ジャッジ日時 2024-05-02 08:59:35
合計ジャッジ時間 19,130 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
17,440 KB
testcase_01 AC 25 ms
10,752 KB
testcase_02 AC 25 ms
10,624 KB
testcase_03 AC 26 ms
10,624 KB
testcase_04 AC 25 ms
10,624 KB
testcase_05 AC 24 ms
10,496 KB
testcase_06 AC 24 ms
10,496 KB
testcase_07 AC 24 ms
10,624 KB
testcase_08 AC 24 ms
10,624 KB
testcase_09 AC 24 ms
10,496 KB
testcase_10 AC 25 ms
10,624 KB
testcase_11 AC 24 ms
10,624 KB
testcase_12 AC 993 ms
79,124 KB
testcase_13 AC 167 ms
16,768 KB
testcase_14 AC 1,837 ms
147,088 KB
testcase_15 AC 1,121 ms
92,464 KB
testcase_16 AC 1,961 ms
154,020 KB
testcase_17 AC 648 ms
49,384 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 671 ms
55,276 KB
testcase_21 AC 475 ms
40,152 KB
testcase_22 AC 677 ms
68,840 KB
testcase_23 AC 675 ms
68,844 KB
testcase_24 AC 490 ms
62,560 KB
testcase_25 AC 507 ms
62,568 KB
testcase_26 AC 60 ms
16,096 KB
testcase_27 AC 314 ms
56,420 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
alpha_set = set(list(S))
A = [{s:0 for s in alpha_set} for _ in range(len(S)+1)]
for i, s in enumerate(S):
    i += 1
    for key in A[i]:
        A[i][key] += A[i-1][key] 
    A[i][s] += 1 
# print(A[-1])
ans = 0
for i in  range(len(S)):
    s = S[i]
    for key in A[i]:
        if s == key:
            continue
        ans += A[i][key]*(A[i][key]-1)//2
        # print(s,key, A[i][key]*(A[i][key]-1)//2)
print(ans)
0