Round Table
InterviewTime limit2sMemory limit1024 MB
Arrange m boys and n girls in a circle to maximize how many people have the neighbor pattern that makes them active, and output one such seating.
- Level
Medium5 of 10
- Topics
- Greedy, String, Math, Implementation
- Solved
- No attempts yet
Problem
Reviving the old traditions of English knights, in one city the members of a school computer science club gather around a round table every week and discuss the results of recent contests.
The club advisor Ivan Petrovich recently noticed that not all the students take an active part in the discussion. After watching several club meetings, he noticed that a member's activity depends on who sits next to them.
There are boys and girls in the club. Ivan Petrovich noticed that a boy takes an active part in the discussion only when girls sit immediately next to him on both sides, and a girl takes an active part in the discussion only when a boy sits next to her on one side and a girl on the other.
Wanting to make the club meeting as interesting as possible, Ivan Petrovich decided to seat the members around a round table so that as many members as possible take an active part in the discussion.
Given the numbers and , write a program that outputs a way to seat boys and girls around a round table such that the maximum number of club members take an active part in the discussion.
Input
The input file contains two integers and separated by exactly one space (, , ).
Output
The output file must contain a single line with characters «B» (uppercase Latin letter) and characters «G» (uppercase Latin letter) arranged in some order. The character «B» denotes a boy, and «G» denotes a girl.
The characters must be arranged in the order in which the club members are to be seated around the table. Adjacent characters correspond to members who sit next to each other. The members corresponding to the first and last characters of the output line also sit next to each other.
Hint
In the first example, all club members take an active part in the discussion.
In the second example, the boys take an active part in the discussion and the girls do not. In this example the members can also be seated as follows: «BBGG». In that case both girls take an active part in the discussion and the boys do not. It is impossible to seat everyone so that three or four club members take an active part in the discussion.