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 ...
随机推荐
- Jmeter之乱码 (一)
Jmeter历史版本下载: http://archive.apache.org/dist/jmeter/binaries/ Jmeter3.0接口测试脚本POST请求主体中的中文无法正确显示,现象如下 ...
- 老白关于rac性能调优的建议
RAC应用设计方面需要在底层做很有设计.虽然ORACLE的售前人员总是说RAC的扩展性是透明的,只要把应用分到不同的节点,就可以平滑的扩展系统能力了.而事实上,RAC的CACHE FUSION机制决定 ...
- What is an Activation object in JavaScript ?
********************* from Professional JavaScript for Web Development Execution Context And Scope T ...
- 求第n个质数
输入一个不超过 10000 的正整数 n,求第n个质数 样例输入 10 样例输出 29 题目地址 #include<stdio.h> #include<math.h> int ...
- 自动部署脚本-bash
from here !/bin/bash Check if user is root if [ $(id -u) != "0" ]; then Echo_Red "Err ...
- java并发编程 线程间协作
线程间协作 1. 等待和通知 等待和通知的标准形式 等待方: 获取对象锁 循环中判断条件是否满足,不调用wait()方法 条件满足执行业务逻辑 通知方: 获取对象所 改变条件 通知所有等待在对象的线程 ...
- centos v7.0配置sftp
需求: 1.建立三个sftp帐号,admin,test1,test22.三个帐号分别在/home/sftp下拥有相应的目录3.test1和test2只能进入自己的目录,admin可以进入三个目录(ch ...
- sklearn.preprocessing.StandardScaler数据标准化
原文链接:https://blog.csdn.net/weixin_39175124/article/details/79463993 数据在前处理的时候,经常会涉及到数据标准化.将现有的数据通过某种 ...
- C#后台正则表达式
static Regex RegPhone = new Regex(@"^((1[34578][0-9]{1}))\d{8}"); static Regex RegN ...
- 运维日常之机房浪潮服务器硬盘红灯亮起,服务器一直响,raid磁盘红色。。。故障解决方法
按Ctrl+H进入到WebBIOS内,看见的错误如下所示: 错误是PDMissing,只不过维护的IBM服务器错误的磁盘不是第一块,而是第三块而已,不过坏哪块硬盘没有影响,重要的是错误的原因.这种错误 ...