cswork / OAOpen practice workspace

Money ForwardOA #2

Count Tiles in 1D Othello

Estimated MediumJudge-ready

Topics (AI-labelled)SimulationIn-place Arrays

Initially the board holds a black tile and a white tile, from left to right. Each character of the transcript is one move: moves 1, 3, 5, … place black tiles, and moves 2, 4, 6, … place white tiles; L/R means placing at the left/right end of the current row of tiles. After a move, if there is a nearest tile of the same color in that direction, flip all tiles between the new tile and that tile; otherwise flip nothing. Output the final numbers of black and white tiles.

Input

The input is a transcript string containing only L and R, of length 1..3000. Every move must place a tile.

Output

Output the number of black tiles and the number of white tiles, separated by a single space.

Example 1

Input:

L

Output:

2 1

Example 2

Input:

R

Output:

3 0

Example 3

Input:

LRRL

Output:

5 1

Editorial

Loading solution…