結果

問題 No.2419 MMA文字列2
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-08-25 06:46:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 69,692 KB
最終ジャッジ日時 2023-08-25 10:13:37
合計ジャッジ時間 7,552 ms
ジャッジサーバーID
(参考情報)
judge13 / judge000
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
58,912 KB
testcase_01 AC 111 ms
59,068 KB
testcase_02 AC 104 ms
58,988 KB
testcase_03 AC 110 ms
63,592 KB
testcase_04 AC 112 ms
63,768 KB
testcase_05 AC 106 ms
58,844 KB
testcase_06 AC 103 ms
59,068 KB
testcase_07 AC 93 ms
58,820 KB
testcase_08 AC 96 ms
59,072 KB
testcase_09 AC 89 ms
58,844 KB
testcase_10 AC 105 ms
58,800 KB
testcase_11 AC 111 ms
63,500 KB
testcase_12 AC 127 ms
65,368 KB
testcase_13 AC 112 ms
63,716 KB
testcase_14 AC 143 ms
66,988 KB
testcase_15 AC 131 ms
65,016 KB
testcase_16 AC 145 ms
66,760 KB
testcase_17 AC 104 ms
64,596 KB
testcase_18 AC 144 ms
67,200 KB
testcase_19 AC 149 ms
67,320 KB
testcase_20 AC 124 ms
64,864 KB
testcase_21 AC 120 ms
64,400 KB
testcase_22 AC 186 ms
69,692 KB
testcase_23 AC 200 ms
69,560 KB
testcase_24 AC 200 ms
69,564 KB
testcase_25 AC 187 ms
69,592 KB
testcase_26 AC 119 ms
64,292 KB
testcase_27 AC 182 ms
69,476 KB
testcase_28 AC 192 ms
69,444 KB
testcase_29 AC 206 ms
69,516 KB
testcase_30 AC 192 ms
69,520 KB
testcase_31 AC 189 ms
69,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

S = list(input())[:-1]
S = [ord(s)-ord('A') for s in S]
N = len(S)
ans = 0
dp = [0]*26
for i in range(N):
    s = S[i]
    dp[s] += 1
    for j in range(26):
        if j==s:
            continue
        ans += dp[j]*(dp[j]-1)//2
print(ans)
0