結果

問題 No.2419 MMA文字列2
ユーザー iseeisee
提出日時 2023-08-12 14:18:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 75,640 KB
最終ジャッジ日時 2024-04-30 05:38:18
合計ジャッジ時間 3,053 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
52,888 KB
testcase_01 AC 30 ms
53,056 KB
testcase_02 AC 31 ms
53,152 KB
testcase_03 AC 31 ms
53,008 KB
testcase_04 AC 30 ms
53,492 KB
testcase_05 AC 30 ms
52,436 KB
testcase_06 AC 35 ms
53,212 KB
testcase_07 AC 32 ms
52,868 KB
testcase_08 AC 31 ms
53,216 KB
testcase_09 AC 29 ms
52,460 KB
testcase_10 AC 29 ms
52,952 KB
testcase_11 AC 31 ms
53,888 KB
testcase_12 AC 44 ms
67,792 KB
testcase_13 AC 38 ms
61,644 KB
testcase_14 AC 54 ms
75,096 KB
testcase_15 AC 46 ms
68,816 KB
testcase_16 AC 54 ms
75,064 KB
testcase_17 AC 41 ms
65,456 KB
testcase_18 AC 57 ms
75,148 KB
testcase_19 AC 57 ms
75,288 KB
testcase_20 AC 43 ms
65,368 KB
testcase_21 AC 40 ms
62,392 KB
testcase_22 AC 71 ms
75,508 KB
testcase_23 AC 72 ms
75,420 KB
testcase_24 AC 70 ms
75,324 KB
testcase_25 AC 70 ms
75,300 KB
testcase_26 AC 42 ms
63,444 KB
testcase_27 AC 78 ms
75,552 KB
testcase_28 AC 74 ms
75,536 KB
testcase_29 AC 74 ms
75,640 KB
testcase_30 AC 74 ms
75,556 KB
testcase_31 AC 72 ms
75,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def main():
    # 入力
    S = input()
    N = len(S)
    # 計算・出力
    prev = {s:0 for s in ALPHABET}
    next = {s:0 for s in ALPHABET}
    for s in S:
        next[s] += 1
    ans = 0
    for i, s in enumerate(S):
        next[s] -= 1
        ans += prev[s] * (N-i-1 - next[s])
        prev[s] += 1
    print(ans)

if __name__ == "__main__":
    main()
0