結果
| 問題 |
No.2419 MMA文字列2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-23 00:46:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 272 ms / 2,000 ms |
| コード長 | 398 bytes |
| コンパイル時間 | 341 ms |
| コンパイル使用メモリ | 82,384 KB |
| 実行使用メモリ | 140,180 KB |
| 最終ジャッジ日時 | 2024-12-20 01:18:24 |
| 合計ジャッジ時間 | 6,041 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
S = list(input())
n = len(S)
DP = [[0 for _ in range(26)] for _ in range(n + 1)]
ans = 0
for i in range(n):
idx = ord(S[i]) - ord('A')
for j in range(26):
if j == idx:
DP[i + 1][j] = DP[i][j] + 1
else:
DP[i + 1][j] = DP[i][j]
for j in range(26):
if j == idx:
continue
ans += DP[i][j] * (DP[i][j] - 1) // 2
print(ans)