시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 140 | 87 | 71 | 63.964% |
Yunee is studying English vocabulary. Among many words that Yunee has learned, "success" is Yunee's favorite word and "failure" is Yunee's least favorite word.
Yunee noticed that two identical characters appear in a row in the word "success" but not in the word "failure." So Yunee decided to call a string "successful string" when it has a property of the word "success." Formally, a string $S$ is a successful string when there is a position $i$ such that $S_i = S_{i+1}$. Here $S_i$ denotes the $i$-th character of $S$.
Yunee wants to count how many successful strings there are among the substrings of a given string. Help Yunee write a program that counts the number of successful substrings. You have to consider two substrings distinct when their positions are different, even if the two strings are the same.
The first line contains an integer $N$ that represents the length of a string. $(1 \leq N \leq 10^6)$
The second line contains a string of length $N$ consisting of lowercase alphabets.
Output the number of successful strings among the substrings of the given string.
7 success
15
"ucc"
, "ccess"
, "ss"
are examples of successful substrings of the string "success"
. On the other hand, "scc"
is not a successful substring, because it is not a substring of "success"
even though it is a successful string.
7 failure
0
4 aaaa
6