Codeforces Round 373 (Div. 1)
E
Matvey's Birthday
Codeforces
3300
原题
← D→
翻译中…

Today is Matvey's birthday. He never knows what to ask as a present so friends gave him a string $*s*$ of length $*n*$. This string consists of only first eight English letters: 'a', 'b', $...$, 'h'.

翻译中…

First question that comes to mind is: who might ever need some string? Matvey is a special boy so he instantly found what to do with this string. He used it to build an undirected graph where vertices correspond to position in the string and there is an edge between distinct positions $*a*$ and $*b*$ ($1 ≤ *a*, *b* ≤ *n*$) if at least one of the following conditions hold:

翻译中…
  1. $*a*$ and $*b*$ are neighbouring, i.e. $|*a* - *b*| = 1$.
  2. Positions $*a*$ and $*b*$ contain equal characters, i.e. $*s*_{*a*} = *s*_{*b*}$.
翻译中…

Then Matvey decided to find the diameter of this graph. Diameter is a maximum distance (length of the shortest path) among all pairs of vertices. Also, Matvey wants to find the number of pairs of vertices such that the distance between them is equal to the diameter of the graph. As he is very cool and experienced programmer he managed to solve this problem very fast. Will you do the same?

翻译中…

Input

翻译中…

The first line of the input contains a single integer $*n*$ ($2 ≤ *n* ≤ 100 000$) — the length of the string.

翻译中…

The second line contains the string $*s*$ itself. It's guaranteed that $*s*$ consists of only first eight letters of English alphabet.

翻译中…

Output

翻译中…

Print two integers — the diameter of the graph and the number of pairs of positions with the distance equal to the diameter.

翻译中…

Note

翻译中…

Consider the second sample.

翻译中…

The maximum distance is $2$. It's obtained for pairs $(1, 4)$, $(2, 4)$, $(4, 6)$ and $(4, 7)$.

翻译中…

样例

Input #1
3
abc
Output #1
2 1
InputCopy OutputCopy
Input #2
7
aaabaaa
Output #2
2 4
InputCopy OutputCopy
题目信息
题号
718E
时间限制
2 s
内存限制
256 MB
标签
位运算
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。