301417: CF266B. Queue at the School
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Queue at the School
题意翻译
# 题目描述 课间休息时,小学生、男孩和女孩在食堂里排成一队。最初孩子们站在食堂里排队。然而,过了一会儿,站在女孩们前面的男孩们开始感到尴尬,下一秒,他们会让身后的女孩站到自己前面。 让我们更精确地描述这个过程。假设队列中的位置由1到n的整数顺序编号,我们对位置号1中的人首先进行操作。如果在时间X,男孩站在第i个位置,女孩站在第i+1个位置,然后下一秒,男孩女孩的位置会交换,也就是此时第i个是女孩,第i+1个是男孩。时间是以秒为单位给出的。 你现在知道孩子们的初始位置。确定队列在T秒之后的排列方式。 # 输入 第一行包含两个整数n和t(1≤n,t≤50),表示队列中的人数和队列将转换成需要查找的排列的时间。 下一行输入一个字符串s,s仅由‘B’和‘G’构成(B表示男孩,G表示女孩) # 输出 输出一个字符串,它描述了t秒后的排列方式。 感谢@HNYLMS_MuQiuFeng 提供翻译题目描述
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.输入输出格式
输入格式
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".
输出格式
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".
输入输出样例
输入样例 #1
5 1
BGGBG
输出样例 #1
GBGGB
输入样例 #2
5 2
BGGBG
输出样例 #2
GGBGB
输入样例 #3
4 1
GGGB
输出样例 #3
GGGB