#P8437. Divine String Construction

    ID: 21613 Type: Default 1000ms 256MiB

Divine String Construction

Divine String Construction

In this problem, a string is called a divine string if every character that appears in the string appears the same number of times. In particular, any nonempty string consisting of only one type of character is a divine string. For any given string \(S\), if some substring of \(S\) is a divine string, that substring is called a divine substring.

The great god TU considers that he likes only those strings which satisfy all of the following conditions:

  1. The string consists only of the characters l and r.
  2. The length of the string is exactly \(n\).
  3. The length of the longest divine substring of the string is exactly \(m\).
  4. The number of consecutive identical characters in the string does not exceed \(k\). (In other words, any maximal block of identical characters has length at most \(k\).)

A substring is defined as a contiguous block of characters within the string. Note that a substring containing only one type of character (for example, lll) is divine since all its (one) character appear the same number of times. Therefore, the longest divine substring in your constructed string will be the maximum among all maximal contiguous blocks as well as any balanced substring (where both characters appear equally often).

Your task is to help the weak god s by constructing a string \(S\) that meets the above conditions. If there are multiple possible answers, any valid one will be accepted.

Note: It is guaranteed that \(m \le k\). Also, observe that when \(m = 1\) a valid solution exists only if \(n = 1\) because any two different characters would form a balanced substring of length 2.

inputFormat

The input consists of a single line containing three space‐separated integers \(n\), \(m\), and \(k\) \( (1 \le m \le k,\; m \le n \le 10^5)\).

outputFormat

Output a string of length \(n\) that is composed only of the characters l and r and satisfies the following:

  • The longest divine substring has length exactly \(m\).
  • No group of consecutive identical characters has length more than \(k\).

If there are multiple valid answers, output any one of them. If no valid string exists, you may output -1.

sample

3 3 3
lll