CodeForces-721A-One-dimensional Japanese Crossword
链接:
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的更多相关文章
- 【76.57%】【codeforces 721A】One-dimensional Japanese Crossword
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 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 ...
- CodeForces 721A
A. One-dimensional Japanese Crossword time limit per test:1 second memory limit per test:256 megabyt ...
- 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 ...
- CodeForces 721A One-dimensional Japanese Crossword (水题)
题意:给定一行字符串,让你输出字符‘B'连续出现的次数. 析:直接扫一下就OK了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024 ...
- codeforces 851C Five Dimensional Points(鸽巢原理)
http://codeforces.com/contest/851/problem/C 题意 - 给出 n 个五维空间的点 - 一个点a为 bad 的定义为 存在两点 b, c, 使的<ab, ...
- Codeforces 850A - Five Dimensional Points(暴力)
原题链接:http://codeforces.com/problemset/problem/850/A 题意:有n个五维空间内的点,如果其中三个点A,B,C,向量AB,AC的夹角不大于90°,则点A是 ...
- Codeforces Gym101518F:Dimensional Warp Drive(二分+高斯消元)
题目链接 题意 给出一个11元组A和11元组B,给出n个11元方程,每个方程有一个日期,要让A变成B,问最少需要日期多少才可以变. 思路 因为日期满足单调性,所以可以二分答案.判断的时候就是高斯消元套 ...
- Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题
A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...
随机推荐
- Java学习之==>IO文件操作体系
一.概述 在整个 Java.io 中最重要的就是5个类和一个接口.5个类指的是 File.InputStream.OutputStream.Reader.Writer,一个接口指的是Serializa ...
- django 视图常用操作
获取参数. 类型是QueryDict https://www.cnblogs.com/zhaoyang-1989/p/11989515.html request.POST.get('参数名') req ...
- 将训练好的tensorflow模型移植到android应用中
具体步骤如下: 1. TFLiteConverter保存模型 修改网络模型代码,将模型通过TFLiteConverter转化成为 TensorFlow Lite FlatBuffer即为.tflit ...
- pycharm修改代码后第一次运行不生效解决
问题: 用pycharm每次修改代码后第一次运行还是原来的结果,运行第二次的时候才是修改后代码的结果 解决: 每次修改代码后保存一下即可解决
- java: (正则表达式,XML文档,DOM和DOM4J解析方法)
常见的XML解析技术: 1.DOM(基于XML树结构,比较耗资源,适用于多次访问XML): 2.SAX(基于事件,消耗资源小,适用于数量较大的XML): 3.JDOM(比DOM更快,JDOM仅使用具体 ...
- token防爆破?
先尝试例如删除token 猜token的值等操作 不行就burp抓包 选择Pitchfork模式.选择要爆破的参数 线程设置为1显然只有获取上一个请求返回的taken值才能,做下一次请求 点击Ref ...
- 解一元二次方程的C++实现
一元二次方程的根的情况分为实根与虚根两种,代码如下 #include<iostream> #include<cmath> using namespace std; float ...
- webdriver中判断元素是否存在的方法
selenium.webdriver中没有内置的判断元素是否存在的方法,所以定义一个方法,如果找到该元素则返回True,否则返回False: from selenium import webdrive ...
- excel常用公式--关联匹配类
index: 根据位置返回单元格的值. match: 根据单元格的值返回位置. index+match替代vlookup rank:返回一列数字的数字排位.数字的排位是其相对于列表中其他值的大小.
- CSS基本样式-背景属性
代码是敲出来的,建议一个一个过一遍 背景属性 背景颜色 background-color 背景颜色 默认值是transparent(透明的) 示例代码 <!DOCTYPE html> &l ...