2023-2024 ICPC, NERC, Northern Eurasia Onsite (Unrated, Online Mirror, ICPC Rules, Teams Preferred) |
---|
Закончено |
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:
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$$$.
3LOL
-1
2LO
1
4LLLO
1
4OLOL
-1
10LLOOOOLLLO
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.
Название |
---|