Artifact Content
Not logged in

Artifact 07f849a6818c5faff70add987ffaac46ac59bbfd


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class BalancedStrings { public:
	vector <string> findAny(int N)
	{
		return solve(N);
	}

	int sim(const vector<string>& S) {
		int cnt = 0;
		for (int i = 0; i < S.size(); ++i)
			for (int k = i + 1; k < S.size(); ++k)
				for (char c1 : S[i])
					for (char c2 : S[k])
						if (c1 == c2)
							++cnt;
		return cnt;
	}

	vector<string> solve(int N)
	{
		if (N <= 26) {
			vector<string> ans;
			for (int i = 0; i < N; ++i)
				ans.push_back(string(1, 'a' + i));
			return ans;
		}

		vector<string> ans;
		for (int i = 0; i < N-2; ++i)
			ans.push_back(string(1, 'e' + i%20));
		int s = sim(ans);
		string a = "b";
		string c = "d";
		while (s && a.size() < 100) a += (a.back()=='a' ? 'b' : 'a'), --s;
		while (s && c.size() < 100) c += (c.back()=='c' ? 'd' : 'c'), --s;
		ans.push_back(a);
		ans.push_back(c);
		return ans;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <string>& Expected, const vector <string>& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, BalancedStrings().findAny(N));}
int main(){

CASE(0)
	int N = 3; 
	string __[] = {"eertree", "topcoder", "arena" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	int N = 4; 
	string __[] = {"hello", "little", "polar", "bear" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	int N = 5; 
	string __[] = {"abbbbbbbbbbbbczaaaaaao", "c", "zz", "c", "xxxyyyzvvv" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	int N = 1; 
	string __[] = {"kkkkkkkkkkkkkkkkkkk" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(4)
	int N = 10; 
	string __[] = {"asdflkjhsdfsfffkdhjfdlshlfds", "pudelek", "xo", "xo", "mnbvmnmbbr", "plox", "qqwwrrttyyy", "you", "are", "awesome" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(5)
	int N = 100; 
string __[] = { "" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(6)
	int N = 40; 
string __[] = { "" };
	  vector <string> _(__, __+sizeof(__)/sizeof(*__)); 
END
}
// END CUT HERE