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

15119번 - Purple Rain 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB141736051.724%

문제

Purple rain falls in the magic kingdom of Linearland which is a straight, thin peninsula.

On close observation however, Professor Nelson Rogers finds that the purple rain is actually a mix of red and blue raindrops.

In his zeal, he records the location and color of the raindrops in different locations along the peninsula. Looking at the data, Professor Rogers wants to know which part of Linearland had the “least” purple rain.

After some thought, he decides to model this problem as follows. Divide the peninsula into n sections and number them west to east from 1 to n. Then, describe the raindrops as a sequence of R and B, depending on whether the rainfall in each section is primarily red or blue. Finally, find a subsequence of contiguous sections where the difference between the number of R and the number of B is maximized.

입력

The input consists of a single line containing a string of n characters (1 ≤ n ≤ 105), describing the color of the raindrops in sections 1 to n.

It is guaranteed that the string consists of uppercase ASCII letters ‘R’ and ‘B’ only.

출력

Print, on a single line, two space-separated integers that describe the starting and ending positions of the part of Linearland that had the least purple rain. These two numbers should describe an inclusive range; both numbers you print describe sections included in the range.

If there are multiple possible answers, print the one that has the westernmost starting section. If there are multiple answers with the same westernmost starting section, print the one with the westernmost ending section.

제한

예제 입력 1

BBRRBRRBRB

예제 출력 1

3 7

예제 입력 2

BBRBBRRB

예제 출력 2

1 5

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2017 Pacific Northwest Region Programming Contest > Division 2 S번

ICPC > Regionals > North America > Southeast USA Regional > 2017 Southeast USA Regional Programming Contest > Division 2 G번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2017 Mid-Atlantic USA Regional Contest C번

  • 문제의 오타를 찾은 사람: rickmccoy
(追記) (追記ここまで)

출처

대학교 대회

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

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