Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Kindergarten Graduation
Description The WeeOnes Kindergarten has a strange ceremony as part of its graduation: The children line up with the girls on the left and the boys on the right with a single space between the boys and the girls. By making a sequence of the following four moves, the children are to end up with all the boys on the left and all the girls on the right with a single space between the boys and the girls.
In each case, the previous position of the child who moved becomes the new open space. For example, with two girls and two boys we begin with: GG_BB the following moves give the desired result: s: GGB_B The teacher would like this process to end in a reasonable amount of time so the parents can go home (the children are probably willing to do this all day). Write a program which takes as input the numbers of girls and boys ( Input The input begins with the number of problems
where *probNumber*increases sequentially from 1 to*N*.*nGirls*is the number of girls.*nBoys*is the number of boys.
There is at least 1 child and at most 24 children in a class. Output For each problem instance, output the problem number at the beginning of the line then a single space, then the number of moves on a line. On each following line, output the codes for the required moves in order. Each line except the last should have 50 move characters with the remainder, if any, on the final line. The last line of a problem instance result should be a single blank line. Sample Input 3 1 2 2 2 4 0 3 5 10 Sample Output 1 8 sHShhSHs 2 2 HH 3 65 sHShhsHHHShhhhsHHHHHshhhhhsHHHHHshhhhhsHHHHHshhhhh SHHHHshhhSHHshS Hint
`ShsHHshS`is also a solution to problem 1`SSSS, HSS,`etc. are also acceptable answers to problem 2.
Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator