結果
| 問題 | No.2419 MMA文字列2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 14:51:40 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
(最新)
TLE
(最初)
|
| 実行時間 | 1,672 ms / 2,000 ms |
| コード長 | 814 bytes |
| 記録 | |
| コンパイル時間 | 425 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 90,788 KB |
| 最終ジャッジ日時 | 2026-05-14 02:39:21 |
| 合計ジャッジ時間 | 23,547 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
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))