链接:

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. java:JSP(JSPWeb.xml的配置,动态和静态导入JSP文件,重定项和请求转发,使用JSP实现数据库的增删改查实例)

    1.JSP的配置: <%@ page language="java" import="java.util.*" pageEncoding="UT ...

  2. 【Java基础】Java创建对象的五种方式

    Java中创建(实例化)对象的五种方式 1.用new语句直接创建对象,这是最常见的创建对象的方法. 2.通过工厂方法返回对象,如:String str = String.valueOf(23); 3. ...

  3. 深入理解java:4.2. 框架编程之Spring框架的设计理念

    什么是Spring呢? Spring是为了解决企业应用开发的复杂性而创建的一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架. Spring优点 简单了解Spring之后,我们看一下Spri ...

  4. selenium学习-ActionChains方法列表

    ActionChains方法列表 click(on_element=None) ——单击鼠标左键 click_and_hold(on_element=None) ——点击鼠标左键,不松开 contex ...

  5. 暴力破解-DVWA_1.9-笔记

     穷举法  通过社工尽可能的缩小密码字典的范围   所用到的工具: Firefox浏览器及其插件Proxy Switcher, OWASP ZAP代理抓包工具. OWASP ZAP  代理抓包工具 h ...

  6. windows jenkins 发布 springboot项目脚本

    windows  jenkins 发布 springboot项目脚本 1.关闭现有程序 (按端口关闭) [与按应用关闭 二选一] @echo off for /f "tokens=1-5&q ...

  7. windows VS2013中使用<pthread.h>

    1. 下载pthreads-w32-2-9-1-realease.zip 地址:http://www.mirrorservice.org/sites/sourceware.org/pub/pthrea ...

  8. 【6.28校内test】T1 Jelly的难题1

    Jelly的难题[题目链接] 废话一句:今天中考出成绩,感觉大家考的都超级棒,不管怎样,愿大家成为最好的自己. 好了废话完了,下面是题解部分: SOLUTION: 首先你可能发生的,是看不懂题: 定睛 ...

  9. 使用CXF开发WebService程序的总结(三):创建webservice客户端

    1.创建一个maven子工程 ws_client,继承父工程 1.1 修改父工程pom配置 <modules> <module>ws_server</module> ...

  10. SpringBoot集合Linux的FastDFS与Nginx上传图片测试错误com.github.tobato.fastdfs.exception.FdfsConnectException: 无法获取服务端连接资源:can't create connection to/192.168.1.104:22122

    报错 com.github.tobato.fastdfs.exception.FdfsConnectException: 无法获取服务端连接资源:can't create connection to/ ...