链接:

https://vjudge.net/problem/CodeForces-721A

题意:

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.Help Adaltik find the numbers encrypting the row he drew.

思路:

模拟算一下,

代码:

#include <bits/stdc++.h>
using namespace std; int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
string s;
int n;
cin >> n >> s;
vector<int> res;
int cnt = 0;
int tmp = 0, in = 0;
for (int i = 0;i < s.length();i++)
{
if (s[i] == 'B')
{
if (in)
tmp++;
else
{
tmp = 1;
in = 1;
}
}
else
{
if (in)
{
res.push_back(tmp);
in = 0;
cnt++;
}
}
}
if (in)
{
res.push_back(tmp);
in = 0;
cnt++;
}
cout << cnt << endl;
for (int i = 0;i < res.size();i++)
cout << res[i] << ' ' ;
cout << endl; return 0;
}

CodeForces-721A-One-dimensional Japanese Crossword的更多相关文章

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

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crossword —— 基础题

    题目链接:http://codeforces.com/contest/721/problem/A A. One-dimensional Japanese Crossword time limit pe ...

  3. CodeForces 721A

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

  4. Educational Codeforces Round 31 B. Japanese Crosswords Strike Back【暴力】

    B. Japanese Crosswords Strike Back time limit per test 1 second memory limit per test 256 megabytes ...

  5. CodeForces 721A One-dimensional Japanese Crossword (水题)

    题意:给定一行字符串,让你输出字符‘B'连续出现的次数. 析:直接扫一下就OK了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024 ...

  6. codeforces 851C Five Dimensional Points(鸽巢原理)

    http://codeforces.com/contest/851/problem/C 题意 - 给出 n 个五维空间的点 - 一个点a为 bad 的定义为 存在两点 b, c, 使的<ab, ...

  7. Codeforces 850A - Five Dimensional Points(暴力)

    原题链接:http://codeforces.com/problemset/problem/850/A 题意:有n个五维空间内的点,如果其中三个点A,B,C,向量AB,AC的夹角不大于90°,则点A是 ...

  8. Codeforces Gym101518F:Dimensional Warp Drive(二分+高斯消元)

    题目链接 题意 给出一个11元组A和11元组B,给出n个11元方程,每个方程有一个日期,要让A变成B,问最少需要日期多少才可以变. 思路 因为日期满足单调性,所以可以二分答案.判断的时候就是高斯消元套 ...

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

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

随机推荐

  1. Python学习之==>面向对象编程(二)

    一.类的特殊成员 我们在Python学习之==>面向对象编程(一)中已经介绍过了构造方法和析构方法,构造方法是在实例化时自动执行的方法,而析构方法是在实例被销毁的时候被执行,Python类成员中 ...

  2. opencv、numpy中矩阵转置,矩阵内的固定位置相应的坐标变换

    opencv.numpy中矩阵转置,矩阵内的固定位置相应的坐标变换

  3. LeetCode.1047-重复删除字符串中的所有相邻重复项

    这是小川的第389次更新,第419篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第251题(顺位题号是1047).给定一个小写字母的字符串S,重复删除两个相邻且相等的字母 ...

  4. ansible自动化运维管理工具

    1.Ansible介绍 1)Ansible:Ansible的核心程序 2)Host Inventory:(默认路径:/etc/ansible/hosts)记录了每一个由Ansible管理的主机信息,信 ...

  5. kettle 连接 mysql8.0 报错的解决办法 org.pentaho.di.core.exception.KettleDatabaseException: Error occurred while trying to connect to the database Error connecting to database: (using class org.gjt.mm.mysql.

    1.下载 mysql8.0 驱动放到 如下目录中 mysql8.0以上的驱动下载链接:mysql-connet-8.0.13 2.配置你连接的数据库 找到如下文件打开编辑 连接信息:下面是我本地的配置 ...

  6. 交换机安全学习笔记 第二章 MAC地址泛洪攻击

    本文为书中相关知识的摘要,由于书中以思科设备为配置依据,所以笔记中补充了华为.H3C设备的相关配置.华为设备配置参考华为S2352EI 产品版本:V100R005C01文档版本:02.  H3C配置参 ...

  7. poj1061(扩展欧基里德定理)

    题目链接:https://vjudge.net/problem/POJ-1061 题意:在一个首位相接的坐标轴上,A.B开始时分别位于X,Y处,每个单位时间向右移动m,n米,问是否能相遇,坐标轴长L. ...

  8. 小记---------linux远程连接集群内其他机器mysql库

    mysql -h -u maxwell -p#10.0.15.145 远程机器ip#-P 注意是大写P 端口#-u 用户#-p 密码

  9. __strong修饰符

    本文用来观察,对于__strong修饰符,编译器为我们自动添加了什么代码,这些代码对于引用计数有什么影响. 例子一 X __strong *x1 = [[X alloc] init]; 使用控制台打印 ...

  10. LayUI 多选框动态加载、启用、禁用、赋值、取值等js实现

    例如多选框如下: <div class="layui-form"> <select xm-select="city"> </sel ...