LCC '22 Contest 4 J5 - Fiducial

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

To congratulate Derek for passing MCR3U (Functions 11), Shane decides to buy Derek a present. In the spirit of problem-solving, he buys him a game called Fiducial.

Fiducial is a multi-player game involving a stack of one black, R red, and G gold tiles. The red and gold tiles are stacked vertically on top of the black tile, and the goal is to be the person that picks up the black tile. During an player's turn, the player picks up the indicator, the top-most tile, keeps it, and makes note of its colour. They will then continue picking up tiles until either the tower runs out, or the tile they pick up has the same colour as the indicator, at which point they will keep that tile and their turn ends. Then, the next player begins their turn.

Derek and Shane decide to play Fiducial with their friends. In total, there are N people playing. To see if Derek's passing grade was a fluke, Shane challenges Derek to set up the stack in such a way that he will win if he goes first. Given the number of red and gold tiles they play with (there will always be one black tile), determine a possible tower configuration such that Derek will win if he goes first, or if it is impossible.

Constraints

1 \le N \le 10^5

0 \le R, G \le 2 \times 10^5

The sum of R + G will not exceed 2 \times 10^5.

Input Specification

The first and only line will contain space-separated integers, N, R, and G.

Output Specification

If a configuration is possible, output a string, representing the initial tower. Any tower configuration will suffice, as long as it is valid. b will always be the first character of the tower, followed by R rs and G gs in some order.

If a configuration is not possible, output -1.

Subtasks

Subtask 1 [10%]

R = 0

Subtask 2 [10%]

G = 1

Subtask 3 [80%]

No additional constraints.

Sample Input 1

4 4 4

Sample Output 1

bggggrrrr

Sample Explanation 1

After Derek's turn, the tower looks like this: bggggrr. After the second player's turn, the tower looks like this: bgggg. After the third and fourth player's turns, the tower looks like this: b. After the fourth player's turn, it is Derek's turn. Thus, he can grab the b and win.

Sample Input 2

2 10 3

Sample Output 2

bgrrrrrrrrgrgr

Sample Input 3

30 15 3

Sample Output

-1

Comments

There are no comments at the moment.