题意:给定一行字符串,让你输出字符‘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. 利用开源工具实现轻量级上网行为审计(来源ispublic.com)

    https://blog.csdn.net/cnbird2008/article/details/5875781

  2. codevs——3064 求和

    3064 求和  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 青铜 Bronze 题解  查看运行结果     题目描述 Description 输入一个数x(x <= ...

  3. 生产环境之Nginx高可用方案

    准备工作: 192.168.16.128 192.168.16.129 两台虚拟机.安装好Nginx 安装Nginx 更新yum源文件: rpm -ivh http://nginx.org/packa ...

  4. HDU1087 Super Jumping! Jumping! Jumping!(LIS)

    题目意思: http://acm.hdu.edu.cn/showproblem.php? pid=1087 此题的意思求最长上升子序列的和. 题目分析: 在求最长上升子序列的时候,不在保存最长的个数, ...

  5. Oracle 10g 升级至10.2.0.4

    http://weihaoluo.blog.163.com/blog/static/224418832010112102355652/   单实例环境 Vmware Server 1.0.6 +Cen ...

  6. 16款创建CSS3动画的jQuery插件

    jQuery插件是用来扩展jQuery原型对象的方法. 本文搜集了用来为你的站点创建CSS3动画的一些jQuery插件. 1. jQuery Smoove Smoove 简化了CSS3转换效果.使得页 ...

  7. 把A表中的a字段和b字段数据 复制到B表中的aa字段和bb字段

    insert into tab2 (column1,column2) select column1,column2 from tab1

  8. 积跬步,聚小流------Bootstrap学习记录(3)

    响应式作为Bootstrap的一大特色.栅格系统可谓是功不可没,既然如此,那我们就来看一下栅格系统是怎样帮助bootstrap实现响应式布局的呢? 1.什么是栅格系统 我们能够从Bootstrap的官 ...

  9. C语言细节笔记1

    /******************************************************************************* ——笔记 1. 函数申明的书写. 可以 ...

  10. 亿部书城李柯毅:Testin云測可大幅提升产品质量 值得推荐!

    亿部书城李柯毅:Testin云測可大幅提升产品质量 值得推荐! 2014/10/13 · Testin · 开发人员訪谈 成立于2010年的亿部书城.其主营业务为移动增值业务及数字出版业务,由中央部委 ...