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

31506번 - ABC String 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 2048 MB102605566.265%

문제

You're given a string consisting of the characters A, B, and C. The string contains the same count of A, B, and C characters.

A string is beautiful if

  • Its length is divisible by 3ドル$.
  • The string can be split evenly into contiguous substrings of size 3ドル,ドル where each substring has one A, one B, and one C, in any order.

For example: ABCCBA is a beautiful string, but ABCAB and CCBAAB are not beautiful.

Given a string, you want to partition it into subsequences (not necessarily contiguous) such that each subsequence is a beautiful string.

For example, for the string ABACBCAACCBB, we can do the following:

AB CA C B
 ACB A C B

This partitions the string into two subsequences ABCACB and ACBACB, both of which are beautiful strings.

For the given string, find the minimum number of subsequences you can partition it into such that each subsequence is beautiful. It can be proven that there is always at least one such partition for all possible inputs that satisfy the input constraints.

입력

The first line of input contains a string $s$ (3ドル \le |s| \le 3 \cdot 10^5$). $|s|$ is divisible by 3ドル$. $s$ contains an equal number of characters A, B, and C.

출력

Output a single integer, which is the minimum subsequences that $s$ can be partitioned into so each subsequence is a beautiful string.

제한

예제 입력 1

ABACBCAACCBB

예제 출력 1

2

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 1 A번

ICPC > Regionals > North America > Pacific Northwest Regional > 2023 ICPC Pacific Northwest Region > Division 2 G번

ICPC > Regionals > North America > South Central USA Regional > 2023 South Central USA Regional Contest > Division 1 A번

ICPC > Regionals > North America > South Central USA Regional > 2023 South Central USA Regional Contest > Division 2 A번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2023 Mid-Atlantic USA Regional Contest > Division 1 A번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2023 Mid-Atlantic USA Regional Contest > Division 2 A번

ICPC > Regionals > North America > Southeast USA Regional > 2023 Southeast USA Regional Programming Contest > Division 1 A번

ICPC > Regionals > North America > Southeast USA Regional > 2023 Southeast USA Regional Programming Contest > Division 2 A번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

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

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