AtCoder Regular Contest 130
翻译中…
Problem Statement
翻译中…
You are given a string $S$ of length $N$. For each $1\leq i\leq N$, let $S_i$ denote the string obtained by deleting the $i$-th character from $S$.
翻译中…
Find the number of pairs of integers $(i,j)$ that satisfy both of the conditions below.
翻译中…
$1\leq i < j\leq N$$S_i = S_j$
翻译中…
Constraints
翻译中…
$2\leq N\leq 3\times 10^5$$S$is a string of length$N$consisting of lowercase English letters.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
7
abbbcca
Output #1
4
Here are the strings $S_i$ in order: `bbbcca`, `abbcca`, `abbcca`, `abbcca`, `abbbca`, `abbbca`, `abbbcc`.
The following $4$ pairs $(i,j)$ satisfy the conditions.
- $(i,j) = (2,3)$
- $(i,j) = (2,4)$
- $(i,j) = (3,4)$
- $(i,j) = (5,6)$
Input #2
4
xxxx
Output #2
6
Input #3
2
pp
Output #3
1
Input #4
2
st
Output #4
0
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。