Largest Smallest Cyclic Shift

AtCoder
IDcode_festival_2017_qualb_f
Time2000ms
Memory256MB
Difficulty
For a string $S$, let $f(S)$ be the lexicographically smallest cyclic shift of $S$. For example, if $S = $ `babca`, $f(S) = $ `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`). You are given three integers $X, Y$, and $Z$. You want to construct a string $T$ that consists of exactly $X$ `a`s, exactly $Y$ `b`s, and exactly $Z$ `c`s. If there are multiple such strings, you want to choose one that maximizes $f(T)$ lexicographically. Compute the lexicographically largest possible value of $f(T)$. ## Constraints * $1 \leq X + Y + Z \leq 50$ * $X, Y, Z$ are non-negative integers. ## Input Input is given from Standard Input in the following format: $X$ $Y$ $Z$ [samples]
Samples
Input #1
2 2 0
Output #1
abab

$T$ must consist of two `a`s and two `b`s.

*   If $T = $ `aabb`, $f(T) = $ `aabb`.
*   If $T = $ `abab`, $f(T) = $ `abab`.
*   If $T = $ `abba`, $f(T) = $ `aabb`.
*   If $T = $ `baab`, $f(T) = $ `aabb`.
*   If $T = $ `baba`, $f(T) = $ `abab`.
*   If $T = $ `bbaa`, $f(T) = $ `aabb`.

Thus, the largest possible $f(T)$ is `abab`.
Input #2
1 1 1
Output #2
acb
API Response (JSON)
{
  "problem": {
    "name": "Largest Smallest Cyclic Shift",
    "description": {
      "content": "For a string $S$, let $f(S)$ be the lexicographically smallest cyclic shift of $S$. For example, if $S = $ `babca`, $f(S) = $ `ababc` because this is the smallest among all cyclic shifts (`babca`, `ab",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "code_festival_2017_qualb_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "For a string $S$, let $f(S)$ be the lexicographically smallest cyclic shift of $S$. For example, if $S = $ `babca`, $f(S) = $ `ababc` because this is the smallest among all cyclic shifts (`babca`, `ab...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments