#GD0000147. Sắp xếp những viên kẹo (Bonbons)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Sắp xếp những viên kẹo (Bonbons)
Bonbons
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
An even-by-even rectangular tray has rows and columns. There are exactly bonbons of type a, of type b, and of type c, with .
Place one bonbon in every cell so that any two cells sharing an edge contain different types. Cells touching only at a corner are not adjacent. Print a valid arrangement or determine that none exists. This is the single-grid Phuoc Hung OJ Extended format.
Input
The first line contains even integers . The second line contains nonnegative integers satisfying .
Output
Print IMPOSSIBLE if no arrangement exists. Otherwise print exactly strings of length using a, b, c, with the exact given counts and no equal orthogonally adjacent characters.
Subtasks
- Subtask 1 (20 points): ; even; ; .
- Subtask 2 (30 points): ; even; ; .
- Subtask 3 (50 points): ; even; ; .
Examples
Input
2 2
2 1 1
Output
ac
ba
Explanation
For a tray with counts , place the two a bonbons on diagonally opposite cells and put b, c in the other cells. All neighboring cells then have different types.