887. Longest Happy String

0

Medium

Alice is fond of the characters 'a', 'b', and 'c'. She defines a string s as happy if it meets the following conditions:
  • s only consists of the letters 'a', 'b', and 'c'.
  • s does not contain any of the substrings "aaa", "bbb", or "ccc".
  • s contains at most a occurrences of the letter 'a'.
  • s contains at most b occurrences of the letter 'b'.
  • s contains at most c occurrences of the letter 'c'. Alice needs your help in finding the longest happy string given three integers a, b, and c.
    If there are multiple longest happy strings, return the lexicographically smallest string.
    If there is no such string, return an empty string "". A substring is a contiguous sequence of characters within a string.
  • Input Format

    The first line of the input contains three integers a, b, and c, representing the number of 'a', 'b', and 'c' respectively.

    Output Format

    Return the largest possible lexicographically smallest happy string.

    Example

    Input

    1 1 7

    Output

    ccaccbcc

    Constraints

    0 <= a, b, c <= 100
    a + b + c > 0
    Loading...

    View Submissions

    Console