Money ForwardOA #2
Count Tiles in 1D Othello
估计中等可在线判题
考点(AI 标注)模拟/实现原地数组
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.
输入格式
The input is a transcript string containing only L and R, of length 1..3000. Every move must place a tile.
输出格式
Output the number of black tiles and the number of white tiles, separated by a single space.
样例 1
输入:
L
输出:
2 1
样例 2
输入:
R
输出:
3 0
样例 3
输入:
LRRL
输出:
5 1