题意:给定一行字符串,让你输出字符‘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. 只有代码不会撒谎,如何通过Spring boot源码查看其对于各个框架的默认配置

    我发现很多开发对于看源码都有种恐惧心理,其实不必这样,大部分优秀的源码写的都挺直观的,很多时候,你在搜索引擎上搜到的一些东西并不一定是对的,但源码肯定造不了假,毕竟不管你怎么想,它就在那里,该是什么意 ...

  2. SQL SERVER 2012 第四章 连接 JOIN の INNER JOIN

    所有JOIN语句的共同点是:将一个记录与另外一个或多个记录匹配,从而生成一个新记录,这个记录是由两个记录的合并列所产生的一个超集. 内部连接: 内部连接语法结构:SELECT <select l ...

  3. Eventquery.vbs

    https://docs.microsoft.com/en-us/previous-versions/orphan-topics/ws.10/cc772995(v=ws.10)

  4. python学习之-项目开发目录规范

    软件目录结构规范有什么好处: 通过规范化,能够更好的控制软件结构,让程序具有更高的可读性. 项目目录组织结构如下: Foo/ # 项目名 --bin/ # 可执行文件目录 --foo # 可执行程序 ...

  5. HDU 1114 【DP】

    题意: 给你空钱袋的质量和装满钱的钱袋的质量. 给你先行的n种货币的面值和质量. 问钱包里的钱最少是多少. 如果质量不可行,输出impossible. 思路: 完全背包. 屌丝有个地方没想通,就是如何 ...

  6. 2018.11.5 PION模拟赛

    期望:30 + 40 + 50 = 120 实际:30 + 50 + 40 = 120 ‘’ 思路:最重要的是发现 是完全没有用的,然后这个题目就可以转成DP来做. /* 期望的分:30 */ #in ...

  7. IE浏览器不能上传图片

    这时将弹出一个“安全设置-Internet选项”对话框,把右侧滚动条慢慢地往下拉. 找到“其他/将文件上载到服务器包含本地目录路径”点击下面的“启用”功能

  8. js:简单的拖动效果

    效果演示:https://jsfiddle.net/dwqs/b5ywws9f/embedded/result/ html: <div class="wrap"> &l ...

  9. 相机标定(Camera calibration)

    简单介绍 摄像机标定(Camera calibration)简单来说是从世界坐标系换到图像坐标系的过程.也就是求终于的投影矩阵 P 的过程,以下相关的部分主要參考UIUC的计算机视觉的课件(网址Spr ...

  10. Leetcode--easy系列10

    #205 Isomorphic Strings Given two strings s and t, determine if they are isomorphic. Two strings are ...