Input
3
BBW
Output
1
2
Input
5
BWBWB
Output
3
1 1 1
Input
4
WWWW
Output
0
Input
4
BBBB
Output
1
4
Input
13
WBBBBWWBWBBBW
Output
3
4 1 3

题意:就是将连续出现的B记录下来并输出。

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define MAX 0x3f3f3f3f
#define fori(a,b) for(int i=a;i<=b;i++)
#define forj(a,b) for(int j=a;j<=b;j++)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const int M=1e5+10;
#define inf 0x3f3f3f
int a[1100];
int main()
{int n,i,j,p=0,e=0,flag=0,k=0;string s;cin>>n>>s;for(i=0;i<n;i++){if(s[i]=='B'){p++;flag=1;//出现连续W只记录一次k=1;//k是记录有没有W}else{if(flag==1){a[e++]=p;p=0;flag=0;}}}if(k==0)//防止出现全为W的情况{cout<<"0"<<endl;return 0;}if(s[n-1]=='B')//防止出现最后一个是B的情况{a[e++]=p;p=0;}cout<<e<<endl;cout<<a[0];for(i=1;i<e;i++)cout<<" "<<a[i];return 0;
}

One-dimensional Japanese Crossword(codeforces 712A)相关推荐

  1. 【codeforces 721A】One-dimensional Japanese Crossword

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  2. Codeforces 712A. Memory and Crow

    题目链接:http://codeforces.com/problemset/problem/712/A 题意: 有两个序列 ai 和 bi, 长度都为 n, 对于序列 ai 满足 ai = bi - ...

  3. Memory and Crow(CodeForces 712A)

    题目描述: There are n integers b1, b2, -, bn written in a row. For all i from 1 to n, values ai are defi ...

  4. Codeforces 712A Memory and Crow

    参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6374955.html [题目链接]  A. Memory and Crow time limit ...

  5. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

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

  6. 【Codeforces】 Round #374 (Div. 2)

    Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...

  7. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  8. Codeforces Round #374 (Div. 2) A , B , C 水,水,拓扑dp

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  9. CCPC-Wannafly Summer Camp 2019 全记录

    // 7.19-7.29 东北大学秦皇岛校区十天训练营,题目都挂在了Vjudge上.训练期间比较忙,没空更博总结,回来继续补题消化. Day1 这天授课主题是简单图论,节奏挺好,wls两小时理完图论里 ...

  10. Codeforces 90B-African Crossword

    African Crossword time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

最新文章

  1. 重磅!全球首个可视化联邦学习产品与联邦pipeline生产服务上线
  2. ​批评代码而不是人!15 年程序员的职场箴言
  3. Linux 执行文件 path,linux可执行文件添加到PATH环境变量的方法
  4. java.util.Queue用法
  5. 【HDU - 1134 】Game of Connections(JAVA大数加法,卡特兰数)
  6. java mysubmail_关于MyBatis10种超好用的写法(收藏)
  7. codeforces Restore Cube(暴力枚举)
  8. SQL SERVER备份脚本
  9. 北京文化:目前《你好李焕英》贡献营收约6000万至6500万元
  10. O - Can you find it?
  11. 组合总和3 leetcode 216
  12. css matrix矩阵,矩阵 | matrix() (Transforms) - CSS 中文开发手册 - Break易站
  13. Spring之AntPathMatcher
  14. UDP 协议报文格式
  15. dell R740secure boot_凯诺 10月13日 DELL 电脑报价
  16. js 获取窗口高度 兼容 各种浏览器
  17. 通过InstallShield官网申请注册码
  18. webpack打包路径更改_webpack打包教程
  19. STC8单片机ADC采样注意事项
  20. liunx oracle 12505,ORA-12505 错误解决

热门文章

  1. C语言-1024小游戏
  2. java使用itextpdf生成 pdf (支持table)分页
  3. 理财学习03-基金类别
  4. python绘制指数函数
  5. 解决海外安卓设备,WIFI“已连接 但无法访问互联网”问题
  6. 关于vmware无法访问互联网
  7. Windows USB功能驱动开发总结
  8. GNU GCC 编译
  9. Autosar之EB的安装与激活
  10. 实现网站二维码扫描登录