A. One-dimensional Japanese Crossword

time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output

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 1 × 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.

第一次打cf,签到题,问黑色块的个数和长度

 //2016.9.30
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 105 using namespace std; string str;
int ans[N]; int main()
{
int n, cnt, tmp;
while(scanf("%d", &n)!=EOF)
{
tmp = cnt = ;
cin>>str;
int len = str.length();
for(int i = ; i < len; i++)
{
if(str[i]=='B')
{
tmp = ;
while(str[i]=='B'&&i<n)
{
i++;
tmp++;
}
ans[cnt++] = tmp;
}
}
cout<<cnt<<endl;
for(int i = ; i < cnt; i++)
{
if(i==)cout<<ans[i];
else cout<<" "<<ans[i];
}
if(!cnt)cout<<endl;
}
return ;
}

最新文章

  1. 关于python的bottle框架跨域请求报错问题的处理
  2. C#语言基础
  3. godaddy域名使用DNSPod做DNS解析图文教程
  4. web cache server方案比较:varnish、squid、nginx
  5. [51单片机] HC-SR04超声波测距仪 基础代码
  6. pip 豆瓣镜像使用
  7. 搭建docker私有仓库,建立k8s集群
  8. nyoj 105 九的余数
  9. HUFFMAN 树
  10. linux禁止root用户直接登录sshd并修改默认端口
  11. EF-CodeFirst-表关系-延迟/贪婪加载
  12. phonegap学习入门
  13. VueI18n插件的简单应用于国际化
  14. DSAPI 提取中间文本(字符串)
  15. datagridview 查询数据库数据
  16. JavaScript状态模式及状态机模型
  17. http协议与https协议
  18. [转帖]NUMA
  19. java web项目为什么我们要放弃jsp?
  20. BootStrap table隐藏列两种方式 (踩坑)

热门文章

  1. vmware中的bridge、nat、host-only的区别
  2. phpmailer 的使用
  3. Jquery 源码学习
  4. 深度学习框架Caffe的编译安装
  5. (简单) POJ 3159 Candies,Dijkstra+差分约束。
  6. LPC1768的usb使用--硬件篇
  7. HTML5语义化标签重构页面
  8. Spring学习---JPA学习笔记
  9. 浅谈一个网页打开的全过程(涉及DNS、CDN、Nginx负载均衡等)
  10. js数组之迭代方法