题干:

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. .INFO域名总量跌破700万,8月第三周净减51,477个
  2. 解决iptables和vsftpd设置的问题
  3. HBase(2) Java 操作 HBase 教程
  4. 软银准备以超400亿美元向英伟达出售Arm,交易最快下周达成
  5. linux内核设计与实现 epub_mongodb内核源码设计实现、性能优化、最佳运维系列-网络传输层模块源码实现四...
  6. Scala 类型、数值类型及类型转换
  7. 计算机音乐组获奖作品,大学生计算机音乐创作类决赛揭晓 浙音6件作品均获奖...
  8. 关于bridge-nf-call-iptables的设计问题
  9. 西南交通大学计算机应用基础,西南交通大学计算机应用基础作业-客观部分
  10. 4.测试用例模板(p2p)
  11. VS2003一点查找按钮就卡死处理方法
  12. hive 漫威the_漫威系列的观看顺序
  13. 预测股票涨跌看什么指标,如何预测明天股票走势
  14. 解决“ Error L6218E Undefined symbol enet_delay (referred from xxxx.o)”问题
  15. 【鼠标事件 MouseEvent】clientX clientY offsetX offsetX pageX screenX screenY
  16. 鸿蒙电视厂商多少人,国产厂商崛起?鸿蒙之后这家厂商也推送了新系统,体验极佳...
  17. 创新未来,走进元宇宙,创造不可思议的数字体验!
  18. mysql数据库编程题题_mysql数据库编程题测试
  19. F28335GPIO结构、寄存器、复用以及注意事项详细叙述
  20. 高赞回答:为什么高级程序员不必担心自己的技术过时?

热门文章

  1. python利用有道词典翻译_使用Python从有道词典网页获取单词翻译
  2. 圆弧齿轮啮合原理_图解八种齿轮的加工原理
  3. 全国计算机等级考试用报名吗,全国计算机等级考试网上报名流程及考生报名使用说明...
  4. linux编译ffmepg,在Ubuntu下编译FFmpeg
  5. python autoit上传文件_结合python+selenium使用AutoIt V3实现文件、图片上传
  6. Redis windows学习(一)——redis安装和基础使用
  7. ArcGIS改变数据集或要素类的的坐标系(投影)
  8. 解决SerMyAdmin无法登陆的问题
  9. Boot Loader的启动流程和开发经验总结
  10. php中的address,html中address是什么意思?(代码示例)