Logo
(追記) (追記ここまで)

26201번 - Finding Maximal Non-Trivial Monotones 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB19415213378.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.

제한

예제 입력 1

7
abababa

예제 출력 1

0

예제 입력 2

7
bababab

예제 출력 2

0

예제 입력 3

10
aababaaabb

예제 출력 3

5

예제 입력 4

10
bbaababaaa

예제 출력 4

5

힌트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona de Programação da SBC 2022 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /