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: Wrong Answer)

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int x,y,z;

int main(void){
	scanf("%d%d%d",&x,&y,&z);
	deque<string> ss;
	string ans="";
	if(x==0 && y==0){
		for(int i=0;i<z;i++){
			ans+='c';
		}
		cout << ans << endl;
		return 0;
	}
	if(x==0){
		for(int i=0;i<y;i++){
			ss.push_back("b");
		}
		int now=0;
		for(int i=0;i<z;i++){
			ss[now]+='c';
			now=(now+1)%y;
		}
		sort(ss.begin(),ss.end());
		int fl=0;
		for(int i=0;i<y;i++){
			if(fl==0){
				string st=ss[0];
				ss.pop_front();
				ans+=st;
			}else{
				string st=ss[ss.size()-1];
				ss.pop_back();
				ans+=st;
			}
			fl=1-fl;
		}
		cout << ans << endl;
		return 0;
	}
	for(int i=0;i<x;i++){
		ss.push_back("a");
	}
	int now=0;
	for(int i=0;i<z;i++){
		ss[now]+='c';
		now=(now+1)%x;
	}
	for(int i=0;i<y;i++){
		ss[now]+='b';
		now=(now+1)%x;
	}
	sort(ss.begin(),ss.end());
	int fl=0;
	for(int i=0;i<x;i++){
		if(fl==0){
			string st=ss[0];
			ss.pop_front();
			ans+=st;
		}else{
			string st=ss[ss.size()-1];
			ss.pop_back();
			ans+=st;
		}
		fl=1-fl;
	}
	cout << ans << endl;
	return 0;
}