| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB | 194 | 152 | 133 | 78.235% |
In this problem we will be dealing with character sequences, often called strings. A sequence is non-trivial if it contains at least two elements.
Given a sequence $s,ドル we say that a chunk $s_i , \dots , s_j$ is monotone if all its characters are equal, and we say that it is maximal if this chunk cannot be extended to left or right without losing the monotonicity.
Given a sequence composed only of characters “a” and “b”, determine how many characters “a” occur in non-trivial maximal monotone chunks.
The input consists of two lines. The first line contains a single integer $N,ドル where 1ドル ≤ N ≤ 10^5$. The second line contains a string with exactly $N$ characters, composed only of the characters “a” and “b”.
Print a single line containing an integer representing the total number of times the character “a” occurs in non-trivial maximal monotone chunks.
7 abababa
0
7 bababab
0
10 aababaaabb
5
10 bbaababaaa
5