题意:给定一行字符串,让你输出字符‘B'连续出现的次数。

析:直接扫一下就OK了。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e5 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
vector<int> v; int main(){
while(scanf("%d", &n) == 1){
string s;
cin >> s;
v.clear();
int cnt = 0;
for(int i = 0; i < n; ++i){
if(s[i] == 'B') ++cnt;
else if(s[i] == 'W' && cnt){
v.push_back(cnt);
cnt = 0;
}
}
if(cnt) v.push_back(cnt);
printf("%d\n", v.size());
for(int i = 0; i < v.size(); ++i){
if(i) putchar(' ');
printf("%d", v[i]);
}
printf("\n");
}
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 Crosswor 水题

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

  3. 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 ...

  4. Educational Codeforces Round 7 B. The Time 水题

    B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...

  5. Educational Codeforces Round 7 A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...

  6. Codeforces Testing Round #12 A. Divisibility 水题

    A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...

  7. Codeforces Beta Round #37 A. Towers 水题

    A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...

  8. codeforces 677A A. Vanya and Fence(水题)

    题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. CodeForces 690C1 Brain Network (easy) (水题,判断树)

    题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...

随机推荐

  1. HDU 1028 整数拆分 HDU 2082 找单词 母函数

    生成函数(母函数) 母函数又称生成函数.定义是给出序列:a0,a1,a2,...ak,...an, 那么函数G(x)=a0+a1*x+a2*x2+....+ak*xk +...+an* xn  称为序 ...

  2. Java后端技术书单

    写博客记录技术上使用的各种问题,这个只能算是一个打游击. 如果要把一个知识学透,最有效的方式就是系统学习,而系统学习就是看书,书本上有清晰的学习路线以及相应的技术栈. 下面是我收集的Java后端的技术 ...

  3. CentOS 5.11安装配置LAMP服务器(Apache+PHP5+MySQL)

    http://www.osyunwei.com/archives/8880.html 准备篇: CentOS 5.x系统安装配置图解教程 http://www.osyunwei.com/archive ...

  4. sqlzoo练习答案--SELECT within SELECT Tutorial

    This tutorial looks at how we can use SELECT statements within SELECT statements to perform more com ...

  5. vi下对齐代码的操作

    时不时会用到,但easy忘,在这里记录一下 1. ctrl + v (选中块) 2. ctrl + f (向前) 或 ctrl +v (向后) 3. 按"=", 把选中的代码对齐

  6. curl_setopt GET的方法

    $ch ") ; curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; curl_setopt($ch, CURLOPT_BINARYTRANSF ...

  7. linux系列之-—03 常见问题

    问题1 描述:Linux如何查看JDK的安装路径 问题2 描述:执行shell脚本时报错,错误信息为:bash: line 19: jar: command not found 原因:因为在系统环境变 ...

  8. [Android]自己定义带删除输入框

    在项目开发中,带删除button输入框也是人们经常常使用到的,该文章便介绍一下怎样创建一个带删除输入框.当中,须要解决的问题例如以下: a)创建自己定义editText类 b)在自己定义editTex ...

  9. Tomcat和Jetty对WebSocket的支持

    公司项目须要,了解了下眼下几种支持WebSocket的框架.曾经用jWebSocket做过一些项目.相对来说.改jWebSocket的源代码略复杂,也不是一天两天能搞定的. 一调研才发现,如今非常多主 ...

  10. react-loadable 进行代码分割的基本使用

    由上篇文章我们可以知道,我的项目,打包后的 js 是 7M 的,首屏就加载 7M 的文件虽然没什么特别大的缺点,但总不是最优的解决办法 因此我们用到了 react-router4 的 react-lo ...