Problem:
Score : 1600 points

Problem Statement

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 as, exactly Y bs, and exactly Z cs.
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

Output

Print the answer.

Sample Input 1

2 2 0

Sample Output 1

abab

T must consist of two as and two bs.

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.

Sample Input 2

1 1 1

Sample Output 2

acb

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>  

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int ma = 1024 * 1024;
const ll mod = int(1e9) + 7;
int x = 4, y = 5, z = 8;
string s;

int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> x >> y >> z;
	s = "";
	vector<string> ss;
	forn (i, x) {
		string t = "a";
		ss.push_back(t);
	}
	forn (i, y) {
		string t = "b";
		ss.push_back(t);
	}
	forn (i, z) {
		string t = "c";
		ss.push_back(t);
	}
	while (sz(ss) > 1) {
		int k = 0;
		forn (i, sz(ss))
			if (ss[i] == ss[0]) k++;
		if (k == sz(ss)) break;
		for (int i = 0; i < k && sz(ss) > k; i++) {
			ss[i] += ss[sz(ss) - 1];
			ss.pop_back();
		}

		sort(ss.begin(), ss.end());
	}
	forn (i, sz(ss)) cout << ss[i];
}