#ABC136D. Gathering Children
Gathering Children
题目描述
Given is a string consisting of L and R.
Let be the length of . There are squares arranged from left to right, and the -th character of from the left is written on the -th square from the left.
The character written on the leftmost square is always R, and the character written on the rightmost square is always L.
Initially, one child is standing on each square.
Each child will perform the move below times:
- Move one square in the direction specified by the character written in the square on which the child is standing.
Ldenotes left, andRdenotes right.
Find the number of children standing on each square after the children performed the moves.
给定的是一个由
L和R组成的字符串 。设 是 的长度。从左到右有 个正方形, 中从左数起第 个字符写在从左数起第 个正方形上。
写在最左边的方格上的字符总是 "R",写在最右边的方格上的字符总是 "L"。
最初,每个方格上都站着一个孩子。
每个孩子将执行下面的移动 次:
- 按照孩子所站方格中书写的字符指定的方向移动一个方格。L "表示左,"R "表示右。
在孩子们做完这些动作后,找出站在每个方格上的孩子的人数。
输入格式
输入内容按以下格式标准输入:
输出格式
按从左到右的顺序,打印孩子们完成移动后站在每个方格上的孩子数量。
样例 #1
样例输入 #1
RRLRL
样例输出 #1
0 1 2 1 1
样例 #2
样例输入 #2
RRLLLLRLRRLL
样例输出 #2
0 3 3 0 0 0 1 1 0 2 2 0
样例 #3
样例输入 #3
RRRLLRLLRRRLLLLL
样例输出 #3
0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0
说明
数据规模与约定
- 是长度介于 和 之间(含)的字符串。
- 的每个字符都是
L或R。 - 的第一个和最后一个字符分别为
R和L。
样例 解释
- 每个孩子走完一步后,从左到右每个方格中站着的孩子数是 。
- 每个孩子走两步后,每个方格上从左到右的孩子数是 。
- 每个棋子走完 步后,每个方格上从左到右的棋子数为 。