A10643 | One-dimensional Japanese Crossword
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
The example of encrypting of a single row of japanese crossword.Help Adaltik find the numbers encrypting the row he drew.
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.
输入格式
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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted