One-dimensional Japanese Crossword(codeforces 712A)
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)相关推荐
- 【codeforces 721A】One-dimensional Japanese Crossword
A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...
- Codeforces 712A. Memory and Crow
题目链接:http://codeforces.com/problemset/problem/712/A 题意: 有两个序列 ai 和 bi, 长度都为 n, 对于序列 ai 满足 ai = bi - ...
- 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 ...
- Codeforces 712A Memory and Crow
参考自:https://www.cnblogs.com/ECJTUACM-873284962/p/6374955.html [题目链接] A. Memory and Crow time limit ...
- Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题
A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...
- 【Codeforces】 Round #374 (Div. 2)
Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...
- 【Codeforces】A2组刷题记录(50 / 50)完结
目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...
- 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 ...
- CCPC-Wannafly Summer Camp 2019 全记录
// 7.19-7.29 东北大学秦皇岛校区十天训练营,题目都挂在了Vjudge上.训练期间比较忙,没空更博总结,回来继续补题消化. Day1 这天授课主题是简单图论,节奏挺好,wls两小时理完图论里 ...
- Codeforces 90B-African Crossword
African Crossword time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
最新文章
- 重磅!全球首个可视化联邦学习产品与联邦pipeline生产服务上线
- ​批评代码而不是人!15 年程序员的职场箴言
- Linux 执行文件 path,linux可执行文件添加到PATH环境变量的方法
- java.util.Queue用法
- 【HDU - 1134 】Game of Connections(JAVA大数加法,卡特兰数)
- java mysubmail_关于MyBatis10种超好用的写法(收藏)
- codeforces Restore Cube(暴力枚举)
- SQL SERVER备份脚本
- 北京文化:目前《你好李焕英》贡献营收约6000万至6500万元
- O - Can you find it?
- 组合总和3 leetcode 216
- css matrix矩阵,矩阵 | matrix() (Transforms) - CSS 中文开发手册 - Break易站
- Spring之AntPathMatcher
- UDP 协议报文格式
- dell R740secure boot_凯诺 10月13日 DELL 电脑报价
- js 获取窗口高度 兼容 各种浏览器
- 通过InstallShield官网申请注册码
- webpack打包路径更改_webpack打包教程
- STC8单片机ADC采样注意事项
- liunx oracle 12505,ORA-12505 错误解决