Codeforces 266B
来源:互联网 发布:关于农副产品的软件 编辑:程序博客网 时间:2024/04/19 05:26
解题:这题就是一道字符串处理问题,判断连续两位是否满足条件,然后交换即可。(如果改变只当前两个数i++移向下一个位置)
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
using namespace std;
char a[51];
int main()
{
int n,m;
while(cin>>n>>m){
scanf("%s",a);
int len=strlen(a);
for(int j=1;j<=m;j++){
for(int i=0;i<len-1;i++){
if(a[i]=='B'&&a[i+1]=='G'){
swap(a[i],a[i+1]);
i++;//这一步很重要
}
}
}
printf("%s\n",a);
}
return 0;
}
阅读全文
0 0
- Codeforces 266B
- codeforces B
- codeforces B
- codeforces B
- codeforces B
- http://codeforces.com/problemset/problem/266/B
- Codeforces Round #266 (Div. 2) B
- Codeforces Round #266 (Div. 2) B & C
- CodeForces-266B Queue at the School
- codeforces 266B Queue at the School
- CodeForces 626B CodeForces 626B【暴力】
- CodeForces 841B (B) 博弈
- codeforces 134B
- codeforces#98 b
- codeforces 105 div2 B
- Codeforces 166B - Polygons
- codeforces B. Coins
- codeforces----193B Xor
- 基于Cocos2d-x学习OpenGL ES 2.0系列——OpenGL ES渲染之Shader准备(7)
- SpringMVC中使用Interceptor处理器拦截器
- mysql格式化日期
- Sqoop ERROR tool.ImportTool: Imported Failed: There is no column found in the target table
- ThreadLocal
- Codeforces 266B
- android 事件分发
- c++中的explicit关键字及隐式类型转换
- 初学四旋翼之光流定点
- Rabbitmq priority 优先级
- Tsung:开源多协议分布式负载&压力测试工具
- 静态变量/非静态变量的区别
- ECMAScript 6新特性简记
- Docker笔记二:Lumen + Redis