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 <string>
#include <iostream>
#include <algorithm>
using namespace std;
string eval(string s) {
	int n = s.size();
	s += s;
	string ans = "~";
	for (int i = 0; i < n; ++i) {
		ans = min(ans, s.substr(i, n));
	}
	return ans;
}
int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int N = X + Y + Z;
	string ans = string(X, 'a') + string(Y, 'b') + string(Z, 'c');
	string cur_ev = eval(ans);
	while (true) {
		// 2-opt
		bool found = false;
		for (int i = 0; i < N && !found; ++i) {
			for (int j = 1; j < N && !found; ++j) {
				for (int k = 0; k <= N - j; ++k) {
					string cyclic = ans.substr(i) + ans.substr(0, i);
					string nxt = cyclic.substr(j, k) + cyclic.substr(0, j) + cyclic.substr(j + k);
					string ev = eval(nxt);
					if (ev > cur_ev) {
						cur_ev = ev;
						ans = nxt;
						found = true;
						break;
					}
				}
			}
		}
		if (!found) break;
	}
	cout << cur_ev << endl;
	return 0;
}