测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10643. One-dimensional Japanese Crossword

编程题 普及/提高-

题目描述

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.

![](/uploads/acgo/image/3388c1e5259899dd_8706963dbe51.jpeg)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 

说明/提示

The last sample case correspond to the picture in the statement.
上一题 去做题 下一题