結果

問題 No.2419 MMA文字列2
ユーザー Kyoro IDKyoro ID
提出日時 2023-08-12 14:51:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 83,584 KB
最終ジャッジ日時 2024-04-30 07:23:02
合計ジャッジ時間 26,799 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
11,904 KB
testcase_01 AC 45 ms
11,904 KB
testcase_02 AC 45 ms
11,904 KB
testcase_03 AC 46 ms
11,904 KB
testcase_04 AC 46 ms
11,904 KB
testcase_05 AC 45 ms
12,032 KB
testcase_06 AC 45 ms
11,776 KB
testcase_07 AC 45 ms
11,904 KB
testcase_08 AC 46 ms
11,904 KB
testcase_09 AC 47 ms
11,904 KB
testcase_10 AC 46 ms
11,904 KB
testcase_11 AC 46 ms
11,904 KB
testcase_12 AC 609 ms
27,648 KB
testcase_13 AC 125 ms
14,208 KB
testcase_14 AC 1,133 ms
42,368 KB
testcase_15 AC 706 ms
30,592 KB
testcase_16 AC 1,161 ms
43,904 KB
testcase_17 AC 376 ms
21,248 KB
testcase_18 AC 1,224 ms
45,312 KB
testcase_19 AC 1,273 ms
46,464 KB
testcase_20 AC 417 ms
22,656 KB
testcase_21 AC 305 ms
19,072 KB
testcase_22 AC 1,383 ms
83,328 KB
testcase_23 AC 1,385 ms
83,584 KB
testcase_24 AC 1,311 ms
83,584 KB
testcase_25 AC 1,312 ms
83,456 KB
testcase_26 AC 181 ms
20,352 KB
testcase_27 AC 1,270 ms
83,456 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import logging
import math
input = sys.stdin.readline
logger = logging.getLogger(__name__)


def read():
    S = input().strip()
    return S,


def nC2(n):
    return n * (n-1) // 2


def solve(S):
    N = len(S)
    count = [[0 for j in range(26)] for i in range(N)]
    for i in range(N):
        s = ord(S[i]) - ord('A')
        for j in range(26):
            count[i][j] = count[i-1][j]
        count[i][s] += 1
    
    ans = 0
    for i in range(1, N):
        s = ord(S[i]) - ord('A')
        for j in range(26):
            if j == s:
                continue
            if count[i-1][j] >= 2:
                ans += nC2(count[i-1][j])
    return ans


if __name__ == "__main__":
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))
0