Two frogs, Thomas and Waymo, are attempting to cross a pond.
Currently, they are both at the starting shore of the pond. In the pond, there are $$$N$$$ rows of unoccupied lily pads. In each row, there are two lily pads, a left lily pad and a right lily pad. One of them is afloat, and one of them is underwater. Also, each lily pad can hold at most one frog.
A frog may jump from the starting shore to an unoccupied and afloat lily pad in the first row, or from a lily pad in one row to an unoccupied and afloat lily pad in the next row, or from a lily pad in the last row to the ending shore.
When a frog jumps from a lily pad, that lily pad goes underwater, and the other lily pad in its row goes afloat. If a frog jumps from the right lily pad in a row, the right lily pad will go underwater, and the left lily pad will go afloat, and vice versa. Also, the frogs are polite. Thus, when one frog is mid-jump, the other frog will not jump.
Thomas and Waymo will jump in any order, obeying the above rules, until they both have made it to the ending shore. When a frog lands on a lily pad on the right, it gains a point. What is the maximum number of points total that Waymo and Thomas can gain?
The first line contains $$$N$$$ ($$$1 \le N \le 100$$$), the number of rows of lily pads.
The second line contains a string $$$s$$$ with characters $$$s_1s_2 \dots s_n$$$. If $$$s_i = L$$$, the left lily pad on the $$$i$$$-th row is currently afloat, and if $$$s_i = R$$$, the right lily pad is currently afloat.
—
Tests in subtasks are numbered from $$$1−20$$$ with samples skipped. Each test is worth $$$\frac{100}{20}=5$$$ points.
Tests $$$1-20$$$ satisfy no additional constraints.
Output the maximum number of points that Waymo and Thomas can earn.
1R
1
A possible jumping order which gains 1 point is:
- Thomas jumps to row $$$1$$$. Thomas lands on the afloat right lily pad and gains a point.
- Thomas jumps to the ending shore. Now, in row $$$1$$$, the right lily pad is underwater, and the left lily pad is afloat.
- Waymo jumps to row $$$1$$$. Waymo lands on the now afloat left lily pad but does not gain a point.
- Waymo jumps to the ending shore. Now, in row $$$1$$$, the left lily pad is underwater, and the right lily pad is afloat.
After both frogs have reached the ending shore, they have gained $$$1$$$ point total.
—
Problem Idea: Alex_C
Problem Preparation: jay_jayjay
Occurrences: Novice A, Advanced A