結果
| 問題 |
No.2419 MMA文字列2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 14:51:40 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 83,456 KB |
| 最終ジャッジ日時 | 2024-11-19 21:56:05 |
| 合計ジャッジ時間 | 26,577 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 TLE * 4 |
ソースコード
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))