4552: 一维日语填字游戏

内存限制:256 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:4 通过:2

题目描述

最近Adaltik发现了日本的填字游戏。日语填字游戏是一幅图画,表示为一个大小为a×b的方格表,每个方格都被染成白色或黑色。在行的左边和列的上面有整数,对相应的行或列进行加密。整数的数量代表对应行或列有多少组黑色方块,而整数本身代表对应组中连续的黑色方块的数量(你可以在维基百科https://en.wikipedia.org/wiki/Japanese_crossword,找到更详细的解释)。
Adaltik认为日本填字游戏的一般情况太复杂了,于是画了一个由n个方块组成的行(例如日本填字游戏的大小为1×n),他想用与日本填字游戏相同的方法对其进行加密。
日本填字游戏单行加密的例子。帮助Adaltik找到他画的那一行的加密数字。


Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a×b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).
Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized n), which he wants to encrypt in the same way as in japanese crossword.
The example of encrypting of a single row of japanese crossword. Help Adaltik find the numbers encrypting the row he drew.
Input
The first line of the input contains a single integer n (1≤n≤100)− the length of the row. The second line of the input contains a single string consisting of n characters 'B' or 'W', ('B' corresponds to black square, 'W'− to white square in the row that Adaltik drew).
Output
The first line should contain a single integer k− the number of integers encrypting the row, e.g. the number of groups of black squares in the row.
The second line should contain k integers, encrypting the row, e.g. corresponding to sizes of groups of consecutive black squares in the order from left to right.
Examples
Input
3
BBW
Output
1
2 
Input
5
BWBWB
Output
3
1 1 1 
Input
4
WWWW
Output
0
Input
4
BBBB
Output
1
4 
Input
13
WBBBBWWBWBBBW
Output
3
4 1 3 
Note
The last sample case correspond to the picture in the statement.

输入格式

输入的第一行包含一个整数n(1≤n≤100)--行的长度。输入的第二行包含一个由n个字符组成的字符串'B'或'W',('B'对应Adaltik画的那一行中的黑色方块,'W'-对应白色方块)。

输出格式

第一行应该包含一个单一的整数k--加密行的整数,例如,该行中黑色方块的组数。
第二行应该包含k个整数,对该行进行加密,例如,对应于从左到右顺序的连续黑色方块组的大小。

输入样例 复制

3
BBW

输出样例 复制

1
2 

数据范围与提示

最后一个样例与声明中的图片相对应。