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

19219번 - Balls of Buma 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB76494868.571%

문제

Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls).

When the ball is inserted the following happens repeatedly: if some segment of balls of the same color became longer as a result of a previous action and its length became at least 3ドル,ドル then all the balls of this segment are eliminated.

Consider, for example, a row of balls 'AAABBBWWBB'. Suppose Balph chooses a ball of color 'W' and the place to insert it after the sixth ball, i. e. to the left of the two 'W's. After Balph inserts this ball, the balls of color 'W' are eliminated, since this segment was made longer and has length 3ドル$ now, so the row becomes 'AAABBBBB'. The balls of color 'B' are eliminated now, because the segment of balls of color 'B' became longer and has length 5ドル$ now. Thus, the row becomes 'AAA'. However, none of the balls are eliminated now, because there is no elongated segment.

Help Balph count the number of possible ways to choose a color of a new ball and a place to insert it that leads to the elimination of all the balls.

입력

The only line contains a non-empty string of uppercase English letters of length at most 3ドル \cdot 10^5$. Each letter represents a ball with the corresponding color.

출력

Output the number of ways to choose a color and a position of a new ball in order to eliminate all the balls.

제한

예제 입력 1

BBWWBB

예제 출력 1

3

예제 입력 2

BWWB

예제 출력 2

0

예제 입력 3

BBWBB

예제 출력 3

0

예제 입력 4

OOOWWW

예제 출력 4

0

예제 입력 5

WWWOOOOOOWWW

예제 출력 5

7

힌트

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2019 B번

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

출처

대학교 대회

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

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