303731: CF721A. One-dimensional Japanese Crossword
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
One-dimensional Japanese Crossword
题意翻译
## 题目描述 最近,阿德蒂克发现了日语填字游戏。日语填字游戏是一幅图片,表示为一张桌子大小的a×b正方形,每个方格都是白色或黑色的。 行的左边和列的顶部都有整数,对相应的行或列进行加密。整数的数量表示对应的行或列中有多少组黑色方块,整数本身表示相应组中连续的黑色方块的数量(您可以在维基百科[https://en.wikipedia.org/wiki/Japanese_crossword](https://en.wikipedia.org/wiki/Japanese_crossword))_纵横字谜中找到更详细的解释)。 阿德蒂克认为日语填字的一般情况太复杂,画了n个正方形(例如1×n1×n)的一行,他想用和日语填字一样的方式加密。 对一行日文横线进行加密的例子。帮助阿德蒂克找到对他画的行进行加密的数字。 ## 输入输出格式 输入格式: 输入的第一行包含单个整数n n(1<=n<=100 1<=n<=100)-行的长度。输入的第二行包含一个由n个字符‘B’或‘W’组成的字符串(‘B’对应于黑色方格,‘W’-与Adtemk绘制的行中的白色方格对应)。 输出格式: 第一行应该包含一个整数k-加密行的整数,例如行中的黑方格组数。第二行应该包含k个整数,对行进行加密,例如,按照从左到右的顺序对应连续黑色方块的大小。题目描述
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](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 $ 1×n $ ), which he wants to encrypt in the same way as in japanese crossword. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF721A/6f8cdbf89b1516bcf9c2878a64fca96ea813c5e6.png)The example of encrypting of a single row of japanese crossword.Help Adaltik find the numbers encrypting the row he drew.输入输出格式
输入格式
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).
输出格式
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.
输入输出样例
输入样例 #1
3
BBW
输出样例 #1
1
2
输入样例 #2
5
BWBWB
输出样例 #2
3
1 1 1
输入样例 #3
4
WWWW
输出样例 #3
0
输入样例 #4
4
BBBB
输出样例 #4
1
4
输入样例 #5
13
WBBBBWWBWBBBW
输出样例 #5
3
4 1 3