CF721A.One-dimensional Japanese Crossword

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a×ba×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 nn squares (e.g. japanese crossword sized 1×n1×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.

输入格式

The first line of the input contains a single integer nn ( 1<=n<=1001<=n<=100 ) — the length of the row. The second line of the input contains a single string consisting of nn 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 kk — the number of integers encrypting the row, e.g. the number of groups of black squares in the row.

The second line should contain kk 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.

首页