博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Queue at the School
阅读量:7005 次
发布时间:2019-06-27

本文共 2157 字,大约阅读时间需要 7 分钟。

B. Queue at the School
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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
Copy
5 1BGGBG
output
Copy
GBGGB
input
Copy
5 2BGGBG
output
Copy
GGBGB
input
Copy
4 1GGGB
output
Copy
GGGB

 

数据范围比较小,根据题意暴力模拟。

#include 
#include
#include
#include
#include
using namespace std;char que[55];int main(){ int n,t; scanf("%d %d\n",&n,&t); scanf("%s",que); for(int i=0;i
View Code

 

转载于:https://www.cnblogs.com/Spacious/p/9366548.html

你可能感兴趣的文章
对MVVM架构的一些理解
查看>>
一个通过物理地址查询网卡所属厂商的Python库——mac.py
查看>>
rundeck yum 安装完成后跳转http://localhost:4440/menu/home问题解决 ...
查看>>
02-Windows Server 2012 R2 会话远程桌面-快速部署(RemoteApp)
查看>>
asp.net 1.1 web.config 讲解
查看>>
Java☞DES加解密算法简介及实现
查看>>
Drupal7核心安装篇-Ubuntu 14.04 LTS
查看>>
ORA-06550 ,has been detected in fnd_global.initialize[fnd_init_sql].
查看>>
android Scroller
查看>>
微信小程序把玩(二)window配置
查看>>
微信公众平台开发(106) 网页获取用户地理位置
查看>>
TEST
查看>>
OpenCV stereo matching BM 算法
查看>>
《Cocos2D权威指南》——3.7 Cocos2D中的单例
查看>>
叫卖“服务” 太阳能光热产品供应商转型
查看>>
芬兰计划以攻击者姿态参与网络战军备竞赛
查看>>
报告|我国47%的县级以上城市提出智慧城市方案
查看>>
SaaS与AI,云客服的天平到底应该偏向哪边?
查看>>
光伏产品出口续增仍要迈坎
查看>>
Silverlight+WCF 新手实例 象棋 棋子移动-吃子(五)
查看>>