题干:

During the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward each second.

Let's describe the process more precisely. Let's say that the positions in the queue are sequentially numbered by integers from 1 to n, at that the person in the position number 1 is served first. Then, if at time x a boy stands on the i-th position and a girl stands on the (i + 1)-th position, then at time x + 1 the i-th position will have a girl and the (i + 1)-th position will have a boy. The time is given in seconds.

You've got the initial position of the children, at the initial moment of time. Determine the way the queue is going to look after t seconds.

Input

The first line contains two integers n and t (1 ≤ n, t ≤ 50), which represent the number of children in the queue and the time after which the queue will transform into the arrangement you need to find.

The next line contains string s, which represents the schoolchildren's initial arrangement. If the i-th position in the queue contains a boy, then the i-th character of string s equals "B", otherwise the i-th character equals "G".

Output

Print string a, which describes the arrangement after t seconds. If the i-th position has a boy after the needed time, then the i-th character a must equal "B", otherwise it must equal "G".

Examples

Input

5 1
BGGBG

Output

GBGGB

Input

5 2
BGGBG

Output

GGBGB

Input

4 1
GGGB

Output

GGGB

题目大意:

输入n(学生人数),t(时间),每秒切换一次位置,为了体现女士优先的绅士风格,站在队列靠前的男生与紧邻靠后的女生交换一次位置,每秒交换一次(一趟下来所有符合条件的都交换一次),求t 秒后,队列分布情况。

解题报告:

就直接模拟就行了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
char s[55];
int main() {int n,t;scanf("%d%d\n",&n,&t);scanf("%s",s);while(t--) {for (int i=0;i<n;) {if(s[i]=='B') {if(s[i+1]=='G') {swap(s[i],s[i+1]);i+=2;} else i++;} else i++;}}printf("%s\n",s);return 0;
}

【CodeForces - 266B 】Queue at the School (模拟)相关推荐

  1. Codeforces Round #249 (Div. 2) (模拟)

    Codeforces Round #249 (Div. 2) (模拟) C. Cardiogram time limit per test 1 second memory limit per test ...

  2. CodeForces - 1248E Queue in the Train(大模拟)

    题目链接:点击查看 题目大意:火车上有n个乘客,编号分别为1~n,编号为i的人会在第ti分钟去打水,水箱每次只能给一个乘客使用,每位乘客都会使用水箱p分钟,当一位乘客想要去打水时,他会先看编号在他前面 ...

  3. Codeforces Round #304 C(Div. 2)(模拟)

    题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...

  4. CodeForces - 1430E String Reversal(线段树+模拟)

    题目链接:点击查看 题目大意:给出一个字符串 sss ,令其反转的串为 ttt ,每次操作可以将 ttt 中的两个相邻位置的字符交换,问最少需要进行多少次操作才能使得 ttt 变成 sss 题目分析: ...

  5. CodeForces - 1362E Johnny and Grandmaster(贪心+模拟)

    题目链接:点击查看 题目大意:给出一个基数 p ,再给出 n 个指数 k ,换句话说,现在有一个长度为 n 的序列,每个元素都是 p^k[ i ] ,现在需要将这个序列分到两个集合中,使得两个集合元素 ...

  6. CodeForces - 1301D Time to Run(构造+模拟)

    题目链接:点击查看 题目大意:给出一个n*m的矩阵,现在每两个格子之间都有一条双向的通道,初始时有个人在左上角的格子中,现在要求这个人精确的走 k 条路,不过每条路只能走一次,但是每个格子可以走无限次 ...

  7. CodeForces - 1303D Fill The Bag(贪心+模拟)

    题目链接:点击查看 题目大意:给出一个背包,容量为 k ,再给出 n 个物品,每个物品的大小保证是 2 的幂次,现在可以进行操作,使得一个物品分为大小相等的,且大小等于原物品一半的两个物品,比如一个物 ...

  8. CodeForces - 91B Queue(单调队列+二分)

    题目链接:点击查看 题目大意:给出一个队列,队列中按照顺序有n只海豹在排队,每一只海豹都有一个数值表示年龄,如果在某只前面有年龄比他小的海豹,他会变得很不开心,不开心的值就是在比他年龄小的海豹中选择距 ...

  9. Codeforces 545D - Queue

    545D - Queue 思路:忍耐时间短的排在前面,从小到大排序,贪心模拟,记录当前等待时间,如过等待时间大于当前的这个人得忍耐时间,那么就把这个人扔到最后面,不要管他了(哼╭(╯^╰)╮,谁叫你那 ...

最新文章

  1. LINQ中的动态排序
  2. 类属性-使用对象名+类属性赋值语句会创建实例属性
  3. Azure Sentinel -- 初探系列二 案件调查及追踪
  4. 【LeetCode】4月4日打卡-Day20-接雨水
  5. JavaScript 需要清楚的10件事
  6. 计算机应用与技术大赛,关于举办2017年燕山大学第一届计算机应用技术与程序设计大赛的通知...
  7. 高德联手饿了么:外卖小哥跑出偏远地区活地图
  8. 《Java数据结构和算法》Seven 高级排序 快速排序
  9. css3特效-传送带示例
  10. 基于 EntityFramework、Autofac 的 UnitOfWork 框架(一)
  11. 简洁大气的网站微信QQ防红跳转代码
  12. Win7重装后修复Ubuntu引导项
  13. 这些信用卡取现可以免除手续费!
  14. 【小5聊】Windows Server R2 SP1 2008鼠标右键新建选项为空
  15. 80286保护模式和实模式的基础概念
  16. java 支付宝 H5支付
  17. opencv实践中遇到的问题
  18. RocketMQ广播消费与集群消费
  19. 虚幻动画蓝图按层级的动画混合(layered)
  20. 蓝字冲销是什么意思_在记账凭证中冲销是什么意思

热门文章

  1. [剑指offer]面试题第[57]题[Leetcode][第167题][JAVA][和为s的两个数字][两数之和][HashSet][二分][双指针]
  2. linux系统中使用pycharn,在pycharm中使用linux控制台
  3. r语言error in match.fun(fun) :_Go语言200行写区块链源代码分析
  4. java io体系_java IO流的体系结构图
  5. python怎么获取时间_Python:如何从datetime.timedelta对象中获取时间?
  6. A20 网卡驱动分析
  7. git 新建分支并切换到该分支_Git何谓分支
  8. 微星主板rgb_虽然这块主板价格有点小贵,但用过之后,感觉还是可以接受的
  9. 提交显示成功但是没有看到文件_如何向RTThread提交一个BSP?
  10. linux 例行性工作,Linux例行性工作