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

33026번 - LOL Lovers 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB23717315972.273%

문제

There are $n$ food items lying in a row on a long table. Each of these items is either a loaf of bread (denoted as a capital Latin letter 'L' with ASCII code 76) or an onion (denoted as a capital Latin letter 'O' with ASCII code 79). There is at least one loaf of bread and at least one onion on the table.

You and your friend want to divide the food on the table: you will take a prefix of this row (several leftmost items), and the friend will take the rest. However, there are several restrictions:

  1. Each person should have at least one item.
  2. The number of your loaves should differ from the number of your friend's loaves.
  3. The number of your onions should differ from the number of your friend's onions.

Find any correct division and print the number of items you take or report that there is no answer.

입력

The first line contains one integer $n$ (2ドル \le n \le 200$) --- the number of food items on the table. The second line contains a string of length $n$ consisting of letters 'L' and 'O'. $i$-th symbol represents the type of the $i$-th food item on the table: 'L' stands for a loaf of bread, and 'O' stands for an onion. It is guaranteed that this string contains at least one letter 'L' and at least one letter 'O'.

출력

Print one integer --- a number $k$ such that, if you take $k$ leftmost items and your friend takes the remaining $n - k$ items, each of you and your friend get at least one item, your number of loaves is different from your friend's, and your number of onions is different from your friend's. If there are several possible answers, print any of them. If there are no possible answers, print the number $-1$.

제한

예제 입력 1

3
LOL

예제 출력 1

-1

예제 입력 2

2
LO

예제 출력 2

1

예제 입력 3

4
LLLO

예제 출력 3

1

예제 입력 4

4
OLOL

예제 출력 4

-1

예제 입력 5

10
LLOOOOLLLO

예제 출력 5

5

노트

In the first example, in any division the left and the right part contain one loaf of bread.

In the second example, the division is 'L' and 'O', and in these two strings the number of loaves is different (1 and 0) and the number of onions is different (0 and 1).

In the third example, any number 1, 2 or 3 is a correct answer.

출처

ICPC > Regionals > Northern Eurasia > Northern Eurasia Finals > Northern Eurasia Finals 2023 L번

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

출처

대학교 대회

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

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