結果
| 問題 | No.2419 MMA文字列2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 14:51:40 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,485 ms / 2,000 ms |
| + 463µs | |
| コード長 | 814 bytes |
| 記録 | |
| コンパイル時間 | 52 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 85,344 KB |
| 最終ジャッジ日時 | 2026-09-26 20:04:10 |
| 合計ジャッジ時間 | 17,687 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_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))