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

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
inputCopy
3
BBW
outputCopy
1
2
inputCopy
5
BWBWB
outputCopy
3
1 1 1
inputCopy
4
WWWW
outputCopy
0
inputCopy
4
BBBB
outputCopy
1
4
inputCopy
13
WBBBBWWBWBBBW
outputCopy
3
4 1 3
Note
The last sample case correspond to the picture in the statement.

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;int main()
{int n;while(cin >> n){string s;cin >> s;int cnt = 0;int a[105];fill(a, a + sizeof(a) / sizeof(int), 1);bool flag = 0;for(int i = 0; s[i] != '\0'; ++i){if(s[i] == 'B' && flag == 0 ){cnt++;flag = 1;continue;}if(s[i] == 'B' && flag )a[cnt]++;if(s[i] == 'W' )flag = 0;}cout << cnt << '\n';for(int i = 1; i <= cnt; ++i)cout << a[i] << ' ';cout << '\n';}return 0;
}

A. One-dimensional Japanese Crossword相关推荐

  1. 【codeforces 721A】One-dimensional Japanese Crossword

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  2. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

    A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...

  3. Codeforces Round #374 (Div. 2) A , B , C 水,水,拓扑dp

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  4. 【Codeforces】 Round #374 (Div. 2)

    Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...

  5. CCPC-Wannafly Summer Camp 2019 全记录

    // 7.19-7.29 东北大学秦皇岛校区十天训练营,题目都挂在了Vjudge上.训练期间比较忙,没空更博总结,回来继续补题消化. Day1 这天授课主题是简单图论,节奏挺好,wls两小时理完图论里 ...

  6. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  7. UVA - 232 ​​​​​​​Crossword Answers

    Crossword Answers UVA - 232 题目传送门 直接按照要求寻找遍历一遍即可 AC代码: #include <cstdio> #include <iostream ...

  8. PHP 多维数组搜索 PHP multi dimensional array search

    array_column() 返回input数组中键值为column_key的列, 如果指定了可选参数index_key,那么input数组中的这一列的值将作为返回数组中对应值的键. 参数 input ...

  9. uva 232 - Crossword Answers(纵横迷宫)

    习题3-6 纵横字谜的答案(Crossword Answers, ACM/ICPC World Finals 1994, UVa232) 输入一个r行c列(1≤r,c≤10)的网格,黑格用" ...

  10. Japanese(Shift-Jis)的编码范围

    // Japanese(Shift-Jis)的编码范围 //全角カナチェック   boolean isZenkaku( char code ) {    return ( code >=0x30 ...

最新文章

  1. 2.4G高频PCB天线设计
  2. 新一代人工智能专利分析
  3. 面试大战 5 轮,我顺利当上饿了么总监!
  4. log4cxx编译过程–linux
  5. 【Darknet-Yolov3】Ubuntu 服务器上无权限出现 ./darknet: error while loading shared libraries: libcudart.so.8.0
  6. ipython和jupyter哪个好_对Python开发者而言,IPython仍然是Jupyter Notebook的核心
  7. JAVA 面试高频提问知识点之:SET、LIST 和 MAP 的区别
  8. Java程序员需要了解的几个开源协议介绍
  9. 【路径规划】基于matlab多种算法无人机路径规划【含Matlab源码 1263期】
  10. 4g模块注册上网 移远_迅为干货 | Linux系统移远EC20 4G模块移植方法
  11. LeetCode||颜色分类--给定一个包含红色、白色和蓝色,一共 *n* 个元素的数组,**原地**对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。
  12. Python 查找算法_众里寻他千百度,蓦然回首那人却在灯火阑珊处(线性、二分,分块、插值查找算法)
  13. unity 物体移动方式的一些笔记
  14. python量化选股策略 源码_【一点资讯】Python实现行业轮动量化选股【附完整源码】...
  15. 天翼宽带政企网关B2-1P 如何获得超级管理员账号?
  16. 解决IE6,IE7,IE8换行显示问题
  17. 利用随机森林算法实现Bank风险预测
  18. 移动端如何解决video层级最高的问题
  19. RK3399 HDCP 2.2key
  20. js 实现多物体动画效果

热门文章

  1. 吴伯凡-认知方法论-T字形认知
  2. 修改某张表的结构_在T-SQL语言中,若要修改某张表的结构,应该使用的修改关键字是Alter。...
  3. 蛋疼菊紧的Outlook 2013
  4. ip 查找计算机,win10系统通过ip地址查找计算机名的详细技巧
  5. 为什么阿里巴巴很少有安全问题的新闻?
  6. 讲解如何在HTML中添加背景图片?
  7. 编1加到100的代码用C语言,用C语言编写一个程序,计算从1加到100的和,并将结果输出。跪求代码,急!...
  8. Visio2——Visio2019任意位置添加连接点
  9. win7笔记本电脑设置WiFi热点
  10. 和python哪个容易胖_哪些吃了最容易长胖呢?