F - Largest Smallest Cyclic Shift Editorial /

Time Limit: 2 sec / Memory Limit: 256 MiB

配点 : 16001600

問題文

文字列 SS に対し、 f(S)f(S)SS の巡回シフトのうち辞書順最小のものとします。 たとえば、 S=S = babca のとき、 SS の巡回シフト (babca, abcab, bcaba, cabab, ababc) のうち最小の ababcf(S)f(S) となります。

あなたは、三個の整数 X,YX, Y, ZZ が与えられます。 あなたは、 a をちょうど XX 個、b をちょうど YY 個、c をちょうど ZZ 個含む文字列 TT を構成したいです。 そのような文字列が複数存在する場合は、 f(T)f(T) を辞書順で最大化したいです。

f(T)f(T) の辞書順での最大値を求めてください。

制約

  • 1X+Y+Z501 \leq X + Y + Z \leq 50
  • X,Y,ZX, Y, Z は非負整数である。

入力

入力は以下の形式で標準入力から与えられる。

XX YY ZZ

出力

答えを出力せよ。


入力例 1Copy

Copy
2 2 0

出力例 1Copy

Copy
abab

TTa 二個と b 二個からならなければなりません。

  • T=T = aabb のとき f(T)=f(T) = aabb.
  • T=T = abab のとき f(T)=f(T) = abab.
  • T=T = abba のとき f(T)=f(T) = aabb.
  • T=T = baab のとき f(T)=f(T) = aabb.
  • T=T = baba のとき f(T)=f(T) = abab.
  • T=T = bbaa のとき f(T)=f(T) = aabb.

となるので、 f(T)f(T) の最大値は abab です。


入力例 2Copy

Copy
1 1 1

出力例 2Copy

Copy
acb

Score : 16001600 points

Problem Statement

For a string SS, let f(S)f(S) be the lexicographically smallest cyclic shift of SS. For example, if S=S = babca, f(S)=f(S) = ababc because this is the smallest among all cyclic shifts (babca, abcab, bcaba, cabab, ababc).

You are given three integers X,YX, Y, and ZZ. You want to construct a string TT that consists of exactly XX as, exactly YY bs, and exactly ZZ cs. If there are multiple such strings, you want to choose one that maximizes f(T)f(T) lexicographically.

Compute the lexicographically largest possible value of f(T)f(T).

Constraints

  • 1X+Y+Z501 \leq X + Y + Z \leq 50
  • X,Y,ZX, Y, Z are non-negative integers.

Input

Input is given from Standard Input in the following format:

XX YY ZZ

Output

Print the answer.


Sample Input 1Copy

Copy
2 2 0

Sample Output 1Copy

Copy
abab

TT must consist of two as and two bs.

  • If T=T = aabb, f(T)=f(T) = aabb.
  • If T=T = abab, f(T)=f(T) = abab.
  • If T=T = abba, f(T)=f(T) = aabb.
  • If T=T = baab, f(T)=f(T) = aabb.
  • If T=T = baba, f(T)=f(T) = abab.
  • If T=T = bbaa, f(T)=f(T) = aabb.

Thus, the largest possible f(T)f(T) is abab.


Sample Input 2Copy

Copy
1 1 1

Sample Output 2Copy

Copy
acb


2025-06-23 (Mon)
20:58:25 +00:00