2015蓝桥真题 (B组国赛)



标题:积分之迷


小明开了个网上商店,卖风铃。共有3个品牌:A,B,C。
为了促销,每件商品都会返固定的积分。


小明开业第一天收到了三笔订单:
第一笔:3个A + 7个B + 1个C,共返积分:315
第二笔:4个A + 10个B + 1个C,共返积分:420
第三笔:A + B + C,共返积分....


你能算出第三笔订单需要返积分多少吗?


请提交该整数,不要填写任何多余的内容。




参考答案:
105


-------------------------
点评:
明显可以暴力破解,只要循环嵌套2层即可。


如果一定想用数学技巧也可以:
3A + 7B + C = 315   ......(1)
4A + 10B + C = 420  ......(2)
求:A + B + C = ?


(2)-(1) 得:A+3B = 105
(1)式变形: 2(A+3B) + (A+B+C) = 315

显然,A+B+C = 315 - 105 * 2 = 105





标题:完美正方形


如果一些边长互不相同的正方形,可以恰好拼出一个更大的正方形,则称其为完美正方形。


历史上,人们花了很久才找到了若干完美正方形。比如:如下边长的22个正方形
2 3 4 6 7 8 12 13 14 15 16 17 18 21 22 23 24 26 27 28 50 60
如【图1.png】那样组合,就是一种解法。此时,
紧贴上边沿的是:60 50
紧贴下边沿的是:26 28 17 21 18


22阶完美正方形一共有8种。下面的组合是另一种:
2 5 9 11 16 17 19 21 22 24 26 30 31 33 35 36 41 46 47 50 52 61
如果告诉你该方案紧贴着上边沿的是从左到右依次为:47 46 61,
你能计算出紧贴着下边沿的是哪几个正方形吗?


请提交紧贴着下边沿的正方形的边长,从左到右,用空格分开。


不要填写任何多余的内容或说明文字。




参考答案:
50 33 30 41


---------------------
点评:
完美正方形问题如果完全没有线索来求解,十分困难。
不过此题给出了诸多线索,暴力破解是可行的。


首先可以确定大正方形的边长。
接下来只要先去枚举3条未知边的所有可能组合情况,剩下中间的情况就很少了。


#include <iostream>
#include <String.h>
using namespace std;
int a[]={2, 5 ,9 ,11 ,16, 17, 19, 21, 22, 24, 26, 30, 31, 33, 35, 36, 41, 50 ,52  };//正方形 
int vis[19];	//访问数组	
int que[30];	// 存储最下行每个正方形大小 
int fon=0;		//最下行正方形索引 
int map[154][154];		//填充为1 未填充为0 

void make(int x,int y,int k,int u)		//填充和清除正方形 	u为1为填充 否则为清空 
{
	if(u==1)
		for(int i=x;i<x+k;i++)
			for(int j=y;j<y+k;j++)
			{
				map[i][j]=1;
			}
	else
		for(int i=x;i<x+k;i++)
			for(int j=y;j<y+k;j++)
			{
				map[i][j]=0;
			}
}

int panduan(int x,int y,int k)		// 当前点 x y 填充大小k 
{
	if(x+k>154)
		return 0;
	if(y+k>154)
		return 0;
	//判断将被填入的正方形部分是否有已经被填充部分 
	for(int i=x;i<x+k;i++)
		for(int j=y;j<y+k;j++)
		{
			if(map[i][j]==1)return 0;	
		}
		return 1;
}
int f(int k)	//k为遍历数组的索引 
{
	if(k>=19)		//完成遍历 
	{
		for(int i=0;i<fon;i++)
			cout<<que[i]<<" ";
		cout<<endl;		
		return 1;
	}
	for(int j=0;j<154;j++)
	for(int i=0;i<154;i++)
		{
			if(map[i][j]==0)	//如果未填充 
			{
				for(int z=0;z<19;z++)		//搜索数组中的正方形 
				{
					if(vis[z]==0 && panduan(i,j,a[z]))	//如果正方形未使用并且符合填充要求 
					{
						int flog=0;
						if(i+a[z]==154)
						{
							 que[fon++]=a[z];
							 flog=1;
						 }
						vis[z]=1;
						make(i,j,a[z],1);
						if(f(k+1)) return 1;		//如果满足要求填充下一块 
						if(flog) 		//如果填过一块,从前一块开始填 
							fon--; 
						vis[z]=0;
						make(i,j,a[z],0);
					}
				}
				return 0;
			}
		}
		return 0;
}
int main()
{	
	make(0,0,47,1);
	make(0,47,46,1);
	make(0,93,61,1);
	f(0);

	return 0;
}





标题:关联账户


为增大反腐力度,某地警方专门支队,对若干银行账户展开调查。


如果两个账户间发生过转账,则认为有关联。如果a,b间有关联, b,c间有关联,则认为a,c间也有关联。


对于调查范围内的n个账户(编号0到n-1),警方已知道m条因转账引起的直接关联。


现在希望知道任意给定的两个账户,求出它们间是否有关联。有关联的输出1,没有关联输出0


小明给出了如下的解决方案:


#include <stdio.h>
#define N 100


int connected(int* m, int p, int q)
{
return m[p]==m[q]? 1 : 0;
}


void link(int* m, int p, int q)
{
int i;
if(connected(m,p,q)) return;
int pID = m[p];
int qID = m[q];
for(i=0; i<N; i++) _____________________________________;  //填空位置
}


int main()
{
int m[N];
int i;
for(i=0; i<N; i++) m[i] = i; //初始状态,每个节点自成一个连通域
link(m,0,1); //添加两个账户间的转账关联
link(m,1,2); 
link(m,3,4); 
link(m,5,6); 
link(m,6,7); 
link(m,8,9); 
link(m,3,7); 

printf("%d ", connected(m,4,7));
printf("%d ", connected(m,4,5));
printf("%d ", connected(m,7,9));
printf("%d ", connected(m,9,2));
return 0;
}




请分析源代码,并提交划线部分缺少的代码。不要填写已有代码或任何多余内容。




参考答案:
if(m[i]==pID) m[i]=qID


正确直接得分,否则把用户答案带入测评代码中的######,运行结果比对:
1 1 0 1 0 0


测评程序为:


#include <stdio.h>
#define N 100


int connected(int* m, int p, int q)
{
return m[p]==m[q]? 1 : 0;
}


void link(int* m, int p, int q)
{
int i;
if(connected(m,p,q)) return;
int pID = m[p];
int qID = m[q];
for(i=0; i<N; i++) ######;
}


void show(int* m)
{
int i;
for(i=0; i<10; i++) printf("%d=%d ", i, m[i]);
printf("\n");
}


int main()
{
int m[N];
int i;
for(i=0; i<N; i++) m[i] = i; //初始状态,每个节点自成一个连通域
link(m,0,1); 
link(m,1,2); 
link(m,3,4); 
link(m,5,6); 
link(m,6,7); 
link(m,8,9); 
link(m,3,7); 
link(m,10,11);
link(m,6,10);

printf("%d ", connected(m,4,7));
printf("%d ", connected(m,4,5));
printf("%d ", connected(m,7,9));
printf("%d ", connected(m,11,4));
printf("%d ", connected(m,9,2));
printf("%d ", connected(m,12,5));
printf("\n");

return 0;
}











标题:密文搜索


福尔摩斯从X星收到一份资料,全部是小写字母组成。
他的助手提供了另一份资料:许多长度为8的密码列表。
福尔摩斯发现,这些密码是被打乱后隐藏在先前那份资料中的。


请你编写一个程序,从第一份资料中搜索可能隐藏密码的位置。要考虑密码的所有排列可能性。


数据格式:


输入第一行:一个字符串s,全部由小写字母组成,长度小于1024*1024
紧接着一行是一个整数n,表示以下有n行密码,1<=n<=1000
紧接着是n行字符串,都是小写字母组成,长度都为8


要求输出:
一个整数, 表示每行密码的所有排列在s中匹配次数的总和。


例如:
用户输入:
aaaabbbbaabbcccc
2
aaaabbbb
abcabccc


则程序应该输出:
4


这是因为:第一个密码匹配了3次,第二个密码匹配了1次,一共4次。




资源约定:
峰值内存消耗 < 512M
CPU消耗  < 3000ms




请严格按要求输出,不要画蛇添足地打印类似:“请您输入...” 的多余内容。


所有代码放在同一个源文件中,调试通过后,拷贝提交该源码。


注意: main函数需要返回0
注意: 只使用ANSI C/ANSI C++ 标准,不要调用依赖于编译环境或操作系统的特殊函数。
注意: 所有依赖的函数必须明确地在源文件中 #include <xxx>, 不能通过工程设置而省略常用头文件。


提交时,注意选择所期望的编译器类型。




用例:

输入:

askfjsahsiafsahifhgafghghhsaggggfhsafsaaskfjsahsiafsahifhgafghghhsaggggfhsafsa
1
hahhgggs

输出:

4

输入:

iskfjhhhsiafsahifgsafghgghssgaasfhsafsaaskfjsghsiafsahifhgaiaaghhaaggggfhisfskaskfjgsssfafhahihhgafghghhsaggggfhhafgaaskajsaasshasaaifahafghghhssgsgsfhsafsghakfjsagsiafsasifhgafghghhsagggffhsafsghskfjshhsaafsagifggsfghghhagggggshfhfsagskfjsfhsiafgghifhgafghghaaaghgaahsafsafskfjsafsiaisahiffgafahghssaggggfhsgfsaaskfjsahssafsahifhgafghghhaagggafhsafsgasffjssfsiafhahifhgafhhghhssgaggghsgfsaaskajsghsigffahifhgafifgshsaggggfhsafsiaskfjsahgiahsahjfhsafghghssggaagshgafsagskfjsahsiafsahifhgaggkghhsfgahffhaafsaaskfjfahsiassahifhgaffhghsgaahggfhaahsaaakgjgaasifhsahifsgafghghhhagaggfasafsahsshfsahsiafhahafhgafahghhsaggagfhhafss
1
hhhggsag

输出:

5

输入:

aakiafahsihasahifhgsfghihhsggahishhsfaaaskfjsahsiafaahgfhgafghghhsaggggfhsafsaaskhjsahgiafsahifhgafhhgfhsafgggfasafsafskfjsaksffffahiahgafghgihssagggfhsasssaakfgsahsiahsahishgafghkhgsahggsihsaisaaakfjsahsihfsaffghfshghghhsagghgihssfsaaakfjsahsiggsahishgafghghasafgggfasafsafhgfjsahshafsahsahgafaagsfsaggggfksahhaaskfjjahsiafsahifhgafghghhsaggggghsafsaasgaisafsisssahhfsgafghhhishggggghsafsaahkaisahsfafsasjghgashhghhsaggggfffafsafsghjahhsiafsihifhgafghghhsaagggfhsfgsagskfjsahsiassahiffgafghghhsfggghfgsafsafskfsssgfiafsahifhgkfghfhgsagaggfhsafgaaskfjsahsgafaahafhgafghghhgaggggfhsaffajfsfjashsiafsahgfhaafghgfhaajggjfhsafss
10
hggagghs
sjfssakh
hfhaggfi
sahsfias
sksjsahf
ifgfahhg
sasifhaj
akjfshas
iasihaff
saijhsaf

输出:

44

输入:

askfjaahsiafssaihhgafghghhsaggfgfhsakgaaskhjsahsiafsasishgafghghhsaggggfhsafsaaskfjsassiafsahifagffghghhsaggggfhsafsaafkfjsahsiassahifggafahghksjggggfhsafhaiskfjsassiagsahifhgafghghhsaggggfhsafsaaskfasghsiafsjjiahgafghghhsagggggfsaasaasffafahsiaasahhfggafghghhshgfhgfgsafiaasggjsghsiafsahifhgafghghhsasgggfhsahsaaskffsahsgafsahifhgffgsgihsaggagfhsafsaafhfjsassigfaahighgafghahhhagiggfhahfsaaskagfghsisfsahifhgafghghhsaggshfhaafsaaskfjssfsiafsahifggsfghfhssaggggfhsassaasgfjsahsiafsahifhgafghghhsaggggfhaafssskafasafsiagsahifsgafghghhkagfggfhsasshaskfjsahsiafsahsfhhafghghasagghgfhsafsaaskfjsahsiagshhifhgafghahhsaagggfhsafshaakfjsaasiafsahhfhgsfghghhsgggggshsassaaskhjsahsiafsahifhgagghghhsaggggfhsafsaaskfjsshsiagsahifhgafghahhfaggggfhsafsasskfjsahsiafsahsfhgafggghhgaigggfhsafsaaskajsahsiafsahihhkafgagghfagggsghfafsfaskfjsassiafsahihhgafghghhsagggafhsafsaaskfjsahsiafgahifhgafghghhsaggggfhsafsaaskfjsahsgakshhifhgafggghhssfgggfgsafiaaskfjsaasiafgahifhgakghgihsagfggfhsafsaahkfjsshiihfsahifhhaighhhhsaggghafsagsasskhjsahaiafhahifhgafggghhshgggffhsafsaasffjsahsaafshhifhgafghghhsaggggfhsafsaaskfjsahsiafsghifhgafgkghhsaggggfgsgffahakfjsahfhafsahifhgafghghhhaggggfhsafgaaskfjsaaaiafsahihhgafgkjhhsaggagfhsafsaaskfjsahsiafsahifhgafghghhsafgggfhsafsaashfjsahhisfaahiahgafghghhsaggakfhsafsajskfhsahgiagsahjfhgafghghhsaggggfhsgfsasskfgsahsiaasahifhgafghhhhsaggggfhsaffiaskfjfahsiafsahifhfafghgafsaggggffsafsaaskfjsahsiafsahifhfafghghhsaagggfhsafsasskfjgghsasfsahifhgafgsghgsahaggfhsafsaasafjsghgaafsahifigafgsgfhgaghjhfhsahsgasifjsahfiafsaisfhaafghghhsaggsgfhsafshasksjsahsgffaahgfhgsfghghhsaggggfhsafsaaskajsahsiafsaaifhgafghghhsgggggfhgsfsaasgfjsahgiaasahifhgafihahhsaggsgagsafsaaskfjsahaiaasahifhgafghshhhaggagfhsafsaaakfjfahsiafsahafhgafhhgghsaggggagsafsaaskfjhahsiafsasifigafghghhsaagggfhsafgassgfjsahsiafsahifhgagghggasaggggfhfafhaaskfjsahsiafsahiahfafghgghsaggggahsafsaaskfjaghsiafsahgfhgafagghhsaggagfhiafsaaskfjsahhiafsaaifhghfshgghsahgggfhsgfsaaskfjsahskafsahifaggfghghhsaggkghhsagshasafjsahsigfsahifhghgghghhsaggggfhsafsaashffsahsiafsahifhgsfghghhsaggggfhssfsaaagfjsahsigfsahighgffghghjsagskgfhsajsaaskahaahsiafsahifhgafjhghssagggffhaafsahskfhsahssafsahifhfafghghhsaggggagsafsaasafssahgiafsahifhgafghghhsaggggfhssfsaaskajhahsiafsahifhgafghghhsaggggfhsafsafskfjfassiafsahifhgafghghhsaggggfhsafsggskfjsahsiafsahifhgsfgaghhsaggggfhsafsaaskfjsgfsifssahifhasfhhghhsaggsgfhskfhaaskhjsahsisfsahifhjffghghhshggggfgsafsaaskfjsahsiassagighgsfghghhsagaggfhsafsafskfjsfhsisfsahifghafghghhsagggkfhfafsiaskgjsahsaafsagifhgafgaghhaaggggahsaffaaskfjiahsiafsahifhgafghghhsaggggfhsaffaaskfsaahsiafsahifhgafghghhsaggggshsafsaaskfassfsiafsfiiffhafghghhsagggsfhaafsaaskfjsghsiafhahifhgafghghhsaggggfhsafsaaskfjsahsiafsaiifsgafghgshsaggggfgsafsaassfhjahsisfsahhfhgagghghhsahgggfhsaffasskfjsahsaassahifhgaighghhsaggggfhsafsaaskfjsahsiafsahifhaafahghhsaggggfhshfsfaskfjsagsiafsahijhgahshghhsagaisfafafsaaskfjsahsiafsahhfhghfghhhhsaggggfhsafsassafjsahasaffahifhfafghfhhssggggfhsafsigskfjsahiiafsahifhgafghghssagaghfhasfsafskfhsahsiassahifagafghghhsagjggfhsafsaahkhssaisiafsahifhggfghghhsagggffhsafsasskfjsshsiafsahsfhgafghfhhsaggggfhsffsaashgjgahaiafsagifhgafghghhsaggggfhsafsaaskfjhhhsiafsahishgafhhghhsaggsffhsafsaakkfjsahsiafsahiahgafghghksfggggfhsafsfaskiasahsiafsahffhsahghghhsaggggghsafsaaikfjiifhiafaafifggafaagfhsagghgghsafsaaakfjsahsiafsahifhgasggghhsaggggfhsafssaskfjsahghafsahifhgasghghhsagggsfhsafsaaskfjsahsiafsihaffgafghghhsaagggfhsafsaaskfjsahsiafshhifhgafghihgsagfggfhsafsaaskijsahsiafgasifhgafgaahfssghggfhsfasgaskfjsahsiafsahifhgasghghhsagghgfhsafsaaskfjsahsiafsjhifhaafshgghsagggsshsafshaskhjsahsiafhahifhggfghghhsagfggfhshfsaahkfjsahaiafsgjifhfafggghhsaggggfjsafsaassffsahiiafsahffhgafghghhsaggggfhsafskasffasahsiafsahifhgafgaghhsaisgsfhhafjaaskfjsahgiaasahifhgafghgfhsaggfgfhfhssaaskfasahsiafgasifhgafghgghsagghgfksffsaaskfjsahsiafsahifhgafghghhsaagghshsffsasikfjhahsiahsafgfhgafahghhsafgfgfhhsfsaaskfjfagsfaisahiffgasghshssaggggfhsahsassafjgahsiaafahifhhafhhghfsagkggahsgfsaaskfjhahsiafhahgfgkaffhghhsaagggfhgafsahskgjsaisiafsahighfkfghgahsaggggfhsifsaaskfjshhsiafsahhfhgagfhgfhsagaggfifafsaaskfjsahsiafsahifhkahghshhsgsgggfhsafsaaskjssaggiafhahifhggfghgihsaggghffsafsaaasfjgahsasfsaiifhgafgaghhsakghffhsagsaaskfjsahsiafsaaifhfhfghfshsaggggfhsafsiasksjsahsiafsahifhgafghghhsafgggfhsassaasafasahsiafhshifhgifgfgahsaggggfhsafsaaskgjsjhsaafsfhifhgafghghhaaggggfhsafsaaskfgsahsiafsahifhhafghghhshggghfhsafsaaskffsahsiafsahifhgafgaghhsaggggfhsafsaasksjaagsiafsahafhghfghghhgaggghfhsafsaaskfjsahaiafsahifhgafghgghsaggggfhsafsaaskfjsahsiafsahafhgafshghhsssgggfhshfsaaskgjsahsiafgshifhgahghghhiaggggfhsagsaaskfjfahsiafhahshfgafghghhsaggggfhshfhaasfhjsahsiafsahifhgafghghhsafgggfhsffsaafkfjsfhsiagaffiahgafghghhsjghgafhsafaaaskfhsahsfaffahfahgafghghhsaggggfhsassaahkfasahsihasahifhkafghgfhkaggggfhsaffaaskfjshhsiafsahifshafghghhfagaggshaaasafskfjfahsiagsahgfhgafshghhsagghafhgafsaafkfksahsiafsahifhgafahghhsaggggfhsahsfahkfjsahsiahsahifhgjfgsghhgaahggghsafsaaskfjgkhiiaasahifhgafgggahsksgggfhsafsaaskjjsahssafhghijhgafghghhsaggggfhsafsaissfjsahsiafsahifhgafghgahsaggggghsafsaaskfjsahsiafsahifhgafghgahsaigsgfhsafsaaskfgsahsiafsaaifhgafggghhsaghghfhsafsaaskijsassiafsahifhgafahgfhsaggggahsahsaaskfasahsiafsahifhfafghghhsaggggfhsafsaskkfgsahsiafsahifsgafghghfsagggsfhsagsahskfjsahaigfsahishgafghghksaggfgfhsafsaasifjsahsiafsaahaggafghgshsagsggfksafsaaskfjsjhsiafsgagfhgafggghhsaggggfhsafsaaagfjsahsiafgahafkgafghghhsaggggffssgfaaskhjsagsgafsasifhgafghghhsagggffhgsfsaasgfjsahsiafaahifhgafghghhsgsgggahsafhfaskfjsahsiassahafhgafghghhhaggggfssafsaaskfisahsijfsahifhgaggaghhsahaggfhhhfsaaskfhsahsiafsahifhgafihghhsaggggghsafsaaskfjsahsiafsagijhhafghghhsaggggfhsafsaaskfjsahsiafsafifhgafghghhsaggagfhsafsagskfjffhsisfsghifhaafhhghhfaggggfhsaffaaskfjsahgiafsahighgafghghhssggggfhshffaaskfjashfiafsshhfaggfghghhsfggggfhsafsasskfjsassiafsahifhgafghghhsaggggfhsafsaaskijsagsiafsahifhgahghghhsfggggfhsafgagskfafshsiafsahighgafshgahsaggggfhsafsaasgfjsahgiahsahifhgafsaghssaggigfhiafsiasffjsahsiakhahifhgafghahfsaiggafhsafsaaskfjsahsiafsaaffhgagahghhsagjgshhsafsjiskfjsahaiafsahifhgafghgshsaghggfhsafsafskffsahsaafsahifhgafasgigsahgggfhsafskaskfjaahsiafsahifhgafghghhsaigggffsafsfaskfjhahsiafsahffhgafghgakhagggghhsafsaaskfjsaisiafsshifhgafghfhhsagggsfhsafssaskajgahhiafsaaishjafghghhssggggsgsafaaasgsjsahsasfsahifhgafghghhsaggggfhhafgaaskffsaassafgahighgafghghhsaggiffgssfsaaskfjaahsiafsahifhgafhhghhsaggggfhgaffsaskfgsahsiafsahifhgafghshssahggghhsafsaaskfjsahsiafsasifhgafghghhsaggggffsaasaifkfjsahsiafsahifhggfghgahskfgagajsafsafakfjsahsiafsahifhgafgaghhsaggggfhsifgifskfjsahsiafsahhfagahghghhsaghghfahafsafskfjsihsiafsahifasafghghhsaggagfhsafsaaagfjsahsiahskhifhgahgsghhsaggggfhaafsaaggfjsahsiafshhafhgahghghhsassggfhsafsaahafhsaasiafsahifhgafggghhsaggjgfhsafsaaskajsagsiafsahifhghfghhhhsaggggfhsafsaaskfjsahsiafsahgffgjfgsghhsaggggfhsafsaaskfjsahsiafhihifhgagghghhsaggggshsaassaskfjhaasiafsahifhgafghghgsagggsfhsafsaassfjsjhshgfaahifhgafgsghhsaagggagsafsaaskfjsahsiafshhhfhgafghghhsaggsgfgsafsaaskfjsahjiaffahhfhgafghghhgaskgsfhsafsaashfgsahsigfsaiihfgafahghhsaggggfhshfaaasffhsafsiafsasifhgafghghhsaghgafhsaffaaskfjsahsiafsahifhgafghghhsiggggfhiafsaaskfjsahsihfjahifhgagjhihhsagaggfhsafsaaskhjsahsiffsahifhhagghshhsaggfgfhsafsaaskfjsahsigfsahifhgafshghhssggggfasafsaafkfjsahsiafsahifsgafgighhhagfggfhshasaaskajsahsiafaahifhgafghhahsaggfgshsaffhaskfjsahshafaghifhgafghghhsaggggfhsafsaaskfjsghsiifsahighgafghghfsagsggahsafsaaskfjsafsiaasahhahgafghghhssgggsfhsafsaaskfjsahsiafsafifhgafghahhskgfggfhsafsaaakfasafsiafsahifhgafghakhsaggggshsafsaaskfjaahsiafsahifhgafghhhhsfggggfhsajsaassfjshhsiafsahifhgafghghhgaggggfhsaaaaahkfjsahsifasahgfhgafghghgsaggggfhhafgaaskfjsahsiafjahifhgafhsfhhsaggggfhhafsaaskfjsagsihfsahifhgafghghhsaggggfhsafsaahkfjsahsiafsahifhgafgaghhsasgggfhfafsaasksjsahsiffsahihhgaaghhhhsaggggfhshfsaashfjaaasgafsahihfgafghghhgaggggfhshgsaaskfgsahsihfsshifhgafahghhsaggggfaaahsaasifjsshsiafsahifhaafgagsfsagggifhsafsaaskfjsahsiafhahifhgafghghhsaggggfhsafsaaskfjsahssafsahishgafghghhsagggghhsagaafskfjsahagafsahishgafghghhsaggfgfhsfhsaaskfjshhsiassahifhgafghghhsaggagfhsaasaaskfashhsiafsajifhghfghghhsaggggfhsafsaaakjjsahhsafsshifhaafihghhsahgggfhsassfassfjsahsihfsahifhgafghgassaggggfhaafsaasasjfaasiafsshishgafghghfsaggggfgsafsaaskfgsahsiafsjhifhfafghghhsagkggfhsaasagsksjsahsigfsahffhaafghghasahgggfhsahsaiskfjsahsiafsfhifsgafghghssaggggfhsafsaaskfjsahsfafsahsfhgsfghgghssgggffgsafsaasafjfahsiafsaaifhghfghghhhaggggfhsahsaagkfjsahsiffsajiajgafgaghgsasgggfhssfsfaskfjsahsiafsahifhgaffhghhsahgggfhaafsaasgfasahsiffsahifhgsfghgahsaggggfhaafsafskfjsahsiahssgifhghfghghsiaggggfhsaffaaskfgsahfiafsahishhafghghgsagfggfhsafssagkfjahhsiafsahifhgafghghhsaggggghsafsaasggjsahfiafsahifhgafghghisaggggihsgsshaikfjsahsiafsahifhgafgashhsaggfgfhaafshaskffsagsiafsaiifhgafghghhsagggsfhsafsaaskfjsahsiafsahifhggfghghhsaagggfhsafsaaskfjgahsiafaahifhgafggghhsagjsgfhhagsaaskfgsagsgafsahifsgafggghhsaggggfhsafsfaskkjsfhsiafsahsfhgafahghhsaggggfhaafsaaskfjsahsiafgahiahhagghghhsagkggfhsafsaaskfjsahsiafsahafhgafshghhsaggggfhsafsaagafjsahgiafsffsfhhafghhfhsfsgghfhssfsaaskgjsahsiafsghijhsafghghhsfggggfhsafsaaskfjsahsiafsahgfhgsfghghhsaggggahskfshaskfssahsiafshhifhgafghhhhsaagggfhsahgaaskfjsahsiffgahifhgaaahghasaggggfhgafsaaskfjaahsiafsahifhkhfghghhsaggggfhsffahaskfjsahsiafshhighgafggshhsaggggshsafsaaskgjsaakgafssgifhgafgsgkssaggggfhsafsaaskfjsahssaahahifhgakghghhsagaggfhsafskahkajsahsigfsahifhgafghghhsaggggfhsafsaaskfjsahsiafskhifhahfghfhhsfgsggfhgafsaggkfjhahasgfsahifhgafghghhsaggggfhsagsaasafjsahaiafsahifhgafghgghsaggggshsassaasafjsahsaafsahifhgafggghhsagggafhsaksaaskfjsahsiafsahifhgafghghhsaggggfhsafsaaskfjihhsiafsahifhgafghghhsaggggahsafshasafjaafsiafsahafhggfghghhsaagggfhsafaaaskfjsfashafsashfhgafghghhsaggggfhsafsaaasgjsahaiffsahsfhgafghghhsaggggfhsjfsggskfjsagsiafsahsfhgahghghhssggggfssaashasafjsghsiafsahifhgafhgghhshggggfhsafsaaskfjsahsssfaagifhgafhhghhaaggggfisafsaasffjsahgiafsghifhgahghghhsaggggfhsafsaashhjsaksiafsahifhgafghghhsaggghfhsafsaaskfjsghaiaffjfifhgafghfhhssgsggffsafsa
10
faashhig
hhgagggs
sfsaihas
ghghsgga
ghghhsag
ffhaiggh
hhgghsag
shghghaf
ghgfahsh
ghgsggfa

输出:

1840

输入:

abbbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbbbbaabbbcccaaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaabcccbabbababbccccaabbccbabbaaabbccccaabcccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbcccbaabbccbabbaabbbccccaabbccbabbaaabbbcacaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaacbccbabcaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaacaccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbcccbaabbccbabbaaabaccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccacbbcccabbaaacbccccaabbccbabbaaabbccccacbbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbcaccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbcccccabbccbcbbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbbbbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbacccaaabccbabbaaabbccccaabbacbabbaabbbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbcababbaabbbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabcccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbbbbaaabbccccaabbcbbabbaaabbcaccaabbccbabcaaabbccccaabbcccabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbbaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbabacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbababbcbccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabaccaabbaaabbccccaabbcccabbaaabbccccaabbccbacbaaabbccccaabcccbabbaaabbccccacabccbabbaacbbccccaabbccbabbaaabbccccaabbcccabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabcccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbbccaaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaaabccacaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabaaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbcbbaaabbccbcaabaccbabbaaabbcccccabaccbabbaaabbccccaababcabbbacabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbcccbbabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaabbbccccaaabccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbacbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaabbbccccaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabaccccaabaccbabbaaabbccccaabbccbcbbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbbcbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccbabbcccabaaabbbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbccabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbbbbaacbcccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccaaacbccbabbaaabbccccaabbacbabbaaabbccccaabbcccabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabcccccaabbacbabbaaabbccccaabbccbabbaaabbcccccabbcababbaaabbccccaabbccbabbaaabbccccaabbcccabbaaabbccccaabbccbabbaacbbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccaabbaaabbbccaaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbbcccabbbccbabbaaabbcccaacbbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbcbbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccacaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaaabccccaabbbcbabbaaabbccccacbbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaaabccacaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbacbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabaccccaabbccbaabaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbbbabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabcccbabbacabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccacbbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbaabaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbcababbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcacccaabbccbabbaaabbccccaabbccbabbaabbbcaccaabbccbabaaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaabbbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbbccacbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaaabccbabbaaabbccccacbbccbabbaaabbccccbaabcbbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbacccbabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabaccbabbaaabaccccaaabccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccacbbcababbaaabbccccaabbccbacbaaabbccccaabbbcbabbababbccccaabbccbabbacabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabaccccaabbccbbbbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabaccbabbaaabbccccabcbccbcbbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcccabbaaaabccccaabbcccabbacabaccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabcaaabcccccaabacccabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbacbabbaaabbcbccacbbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaaabccccaabbccbabbaacbbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabaccbabbacabbccccaabbccbabbaaabbcaccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbbcccaabcccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabaccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabcbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabaaaabbccccaabbccaabbababbccccaabbacbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbccbaaabbccccaabbccbabbacabbcccbaabbccaabbaaabbccccabbbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccacbbccbabbcaabbccccbabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbababbcccccabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabbababbcccccabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabaacabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbacbabbaacbbccccaaabccbabbaaacbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabaaaabbccccaabbccbbbbaacbbccccaabbccbabbaaabbcbccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbcbbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccbabbcccabbaabbbccccaabbacbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbacbbbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbcccabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbcccaaabbccbaabaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbcacccabbccbabbaaabbccccaabbcababbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccaacbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbcccbabbbcccabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccccbbbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccabbbacbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbcbaabbbccccaabbccbabbacabbccccaabaccbabbbaabbccccaabbccbabbaaabaccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbacabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacabccccaabbccbabbaaabbccccaaabccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbcccabbaaabbccacaabbccbabbaaabbccccacbbccbabbaaabbacbcaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaacbbccccaacbccbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaacccaabbccbabbaaabbccccacbbccbabbaaabbccacaabbccbabbaaabbccccaabbccbbbbaaabbcbccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaacbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabcbcccaabbccbabbbaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbacbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbcbccaabbccbabbbaabbccccaabbccbabbaaabbacccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaaabaaabaccccaabbccbabbaaabbccccaabbcababbaaabbccccacbbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbaaabbcaccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbcccbaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabcccacbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbcbbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbcbbaaabbccccaaabccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccbcaabbcababbaaabbcccccbbbccbabcaaabbccccaabbacbabbaaabbacccabbbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbababbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccaabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbcbccaabbccbabbaaabbccccaabbccaabbaaabcccccaabaccbabbcaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbcccabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbbaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbbaabbcaaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaacbaaabbccccaabbccbbbbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbbaabbccccaabbbbbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbcccaaabbcccabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabaccccaabbccbabbaabcbccccaabbccbabbaacbbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbacabbcacaaabbccbaabaaabbccccaabbccbabaaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbbcbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccbabbccbabbaaabaccccaabbccbabcaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccaabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabcccbabbbaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccbccabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbccccaabbcababbaaabbcbccaabbccbabbaaabbcbccaaabccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbcaabbccccaabbccbcbbaaabbccccaabbccbbbbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbcaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbacbabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaacbbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbababbcaccaabbccbabbaaabbccbcaaabccbabbbaabbccccaabbccbabbaabbbccccaabbccbabbaaabbcacccabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbababbccccaabcccbabbaaabbccccacbbccbaabaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbcaccaabbccbabcaacbbcbccaabbccbabbaaabbcccaaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabaaaabbcccbaabbccbabbaaabbccccaabbbcbcbbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcccabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbbcccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccacbbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcaabbccccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbcccabbaaabbccccaabbccaabbaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbacabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacaabccacaabbcccabbababbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbbcbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbcccaaabbccaabbaaabbccccaaabccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccacbbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbbcccaabbccbabbaaabbcbacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaccccccaabbccbabbaaabbccccaabbccbabbbcabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbcccbaabbccbaabaaabaccccbabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbbcbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbbaabbccccaabcccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbabbabbacabbccccaabbccbabbaaabbccccaacbcababbaaabbccccaabbccbcbbaaabbccccaabbccbacbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccaabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccaabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaabccbabbaaabcccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbcccabbaabbbacccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabbcaccaabbccaabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabcccccaabbccbabbaaabbccccaabbccbbbbaaabbacccaabbccbbbbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbcbbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaacbbcbbbbaaabbccbcaabbccbabbaaabbccccbabbccbaabaaabbccccaabbcccabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbcaccaabbccbabbaacbbccccaabbbcbabbaaabbbcccbabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbacabbccccaaabccbabbaaabbccccaabbccbabbcaabbccccabbbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbabbbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccabbbccbabbaaabbccccaabbcbbabcaaabbccccaabcbcbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcaabaccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbccabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabbccccabbbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaaabccccacbbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbcbccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccbcaabbccbabbaaabbccccaabbccbcbbaaabbccccaabaccbabbaaabbcccaaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbcaccaabbcccabbaaabbcccccabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbcaabbccccaabbccbabbaaabacccbaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabaccccaabcccbabbaaabbccccaabbccbabaaaabbccccaabcccbabbaaabbccccaabbccbabbaaabaccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbacbaaabbccccaabbccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbbbbaaacbccccabbbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbaaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacabccccaabbccbabbaaabbccccaabbacbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaacbccbabbaaabbccccaabbccbabbaaabbccccaaabcbbabbaaabbccccaabbccaabbaaabbcaccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbcccabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbcbbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbcbcbaabbccbabbaaacbccccabbbccbabbbaabbccccaabbccbabbababbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaacccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabcaaabbccccbabbccbcbbaaaabccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbcaccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbbbbbaabbccccaabbcccabbaacbbccbcaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbcaabbccbcaabbccbabaaaabbccccaabbccbabbaaabbccccaabbccbacbcaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaacbcababbaaabbccccaabbccbabbaaabbacccaabbccbabbaaabbccccacbbccbcbbaaabbccccabbbccbabbaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbaabbccccaabbccbabbaaacbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbacbabbaaabaccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccabbbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabaaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcaabbaacbbccccaabbccbabbaaabbccbcaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaacbccccaaabcccbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbaabaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccbabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbabacbccccaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbacccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbcbbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbaabaaabbccbcaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabacccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaacbccbbbbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbcbccaabbccbabbaaaabccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcacbabbaaabbccccaabbccbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbccbabbaaabbccccaabbccbabbaaaabccccaabbccbabbaaaabccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbbaabbccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbccccaabbacbabbaaabbccccaabbccbabbaaabbaaccaabbccbabbaaabbcaccaabbccbabbaacbbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbbbbaaabbccccaabbcccabbaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbcbbabbababbccccacbbccbabbaaabbccccaabbccbabbababbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabaccccacbbccbabbaaabbccccaaabccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccabbbccbaabaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababbcbccaabbccbabbaaabbccccaabbccbabbaaabbccbbabbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabbccccaaabccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbababcccccaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcccabbaaabbcccaaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaaabbaccbaabbccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabbccccaabbccbbbbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbcccaaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbcbbaaabbccccaaabccbabbaaabbccccaabaccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbbbbaaabbccccaabbccbabbaabbbccccaabbccbabaaaabbccccaabbccbabbaacbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaaabccbabbaaabbccccaaabccbabaaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabaccbabbcaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbcacbabbaaabbccccaabbccbabbaaabbccccaabbccbacbaacbbccccaabbcababbaaabcccccaabbccbabbaaabbccccaabbccbabbaaabaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabcccbabbaaabbccccaabbccbabbaaabbccccaabbccbabaaaabbccccaabbccbabbaaabbcbccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcababbaaabcccccaabbccbbbbaabbbccccaabbacbabbaaabbccccaabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccaabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaabbbccccaabbacbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbccbabbacabbccccaabbccbbbbaaabbccccbabbccbabbaaabbccccaabbccbabbaacbbcccbaabbccbabbaaabbccccbabbccbabcaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbbcccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbcccabbaaabbccccaabbbcbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcccbaabbccbabbaaabaccccaabbccbabbaaabbccccaabbbcbabbaaabbcccccabbccbabbaaabbccccaabbccbabbaaabbccacaabbccbabbaaabbbaccaabbccbabbaaabbccccaabbccbabbaaabbcaccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbcababbaaabbcccccabbccbacbaaabbcaccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccbcaabbcbbabbaaabbccccaabbcbbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbbabbbccccaabbccbabbaaabbccccaabbccbabbaaabbccccacbbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbacabbccccaabbccbabbaaabbccccaabbccbabbaacbbccccaabbcbbabbaabbaccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbccccaabbccbabbaaabbcbccaabbcbbabbaaabbccccaabbccbabbaaabbccccacbbacbabbaaabbccccaabbccbbbbaaabbbcccacbbccbabbaaabbcaccaabbcccabbaacbbbcccaabbccbabbababbccccaabbbcbabba
500
bcbcabba
babbccbb
bacbaccb
ccacbabc
acbcabbc
bbacccca
bcacbbca
bccbacac
aabbbccb
acbbccac
acbbbcab
cbbbbcab
cccabacb
ccbcacba
abccabcc
aabbbccb
cbacabcb
ccbbccaa
bccccaab
abcccabc
cbccbaca
accbbacc
cabbccac
accabcbc
ccbcacab
caaccbcb
aabbaccb
bbcacaab
abbcccac
cabaccbc
aaccbbcc
cbcccbaa
cccabbac
cbabccba
ccbcbaac
abbacccc
babcacba
ccaabcbc
bccabcca
abbccacc
baccacbc
acaccbcb
cacabbbb
bacccabc
babaccba
cabcbbba
ccbccaba
cacccbab
accbcbac
acccbcba
accacbbc
cbaacbab
aabbccbc
bacacbcc
bcaacbcc
acabbcbb
bbacbcbb
cacacbbc
cbacabbb
cbbcacca
bcabbcca
bcbbabac
acbbbcab
acbccbac
accccbba
cbbacacb
aaaccbbb
aaccbccb
cbbcccaa
ccaacbbc
cbbcacac
aabccccb
cbbcbbba
ccbacbac
ccababcc
ccacbacb
cbccbcaa
cacbbbca
aabbaccb
cccbbaab
cbcbacca
bbacbbbc
bcbcacac
cababccb
baaccccb
abccbbbb
ccaabbcc
ccbaabcc
bccccaba
cccababc
bbccacac
cbbcacca
cbcbcaab
bacccbca
cacabbcc
bbcaccca
baaccbcc
bcbacacc
bccacacb
caccbacb
bccabacc
cccbbaca
ccaabbcc
abccccab
acabcccb
ccbacbac
babbacac
cbcccbaa
bbcccaca
cbbabcbb
cbaacccb
ccacbcab
cbccbaac
bcaacbcc
bcbcbaab
aabcbcba
babbccbb
bbbccbaa
caabbcbc
abccbcac
bacacbbb
ccabbacc
bccbabca
acbbcbca
acabcbba
cbbcbabb
bbbcbcab
cbbcbbab
cccbacab
cccabbca
bbacccca
accccabb
caabcccb
bbbccabb
cabccabc
cabcbbaa
bcbccaca
cbbaccac
bbccaacc
bccabacc
bbbcabca
cccababc
bcbcccaa
accbbacb
abcccacb
bcabccac
bbaccbbb
cbaaccbc
cabbcacc
bbaacccc
abbacbbc
caabbccb
ccbcabca
accacbbc
bacbccac
bccaacbc
cabccbca
cacbaccb
cabccbac
aabccbbb
acbccbac
bacccabc
bbbbcabc
cccaabbc
cbabccca
acbbbaca
accabccb
bbccbaba
babcccca
cbcbcaca
abbacbcb
babbacbc
cabbbcaa
abbabccc
aabbccbc
ccabbacc
ccbcaacb
abcaccbc
bacccbac
cabccabc
ccabbcac
cbccabca
accbaccb
cbbcacac
acbacabb
ccababbb
bcaacccb
cabcabcc
accbbbaa
bcccabac
bbbbaacc
abccbabb
accbaccb
abccaccb
cabccacb
bcbbacaa
bcbbacab
bccbabbb
ccbbbcaa
bcacbcca
ccacbcba
accbaabb
acbbccca
bccccaab
abcccacb
acbacbcc
bccbbbab
cbccbcaa
acbcccba
cabacbcc
accbabcc
abccbcca
cbacbcca
abaaccbb
abcccacb
ccaabbcc
bcabcaba
cbaacbbc
baacbccc
ccabcbac
cacccbab
cbbaacbc
bacccbca
bcccbcaa
cccaacbb
bbbbcbac
abcccacb
cabaccbc
bcabcbba
cbaccbca
bbcccaca
bccbacca
cabbcaab
aacbcbcc
bbacccca
bccbaacc
cacbbacb
cccbbaba
caabcccb
bccacbca
bbacacbb
aabccccb
acbccabc
cccbaabc
cbaaccbc
bccaaccb
cabacbcc
abbccbba
acccabbc
bacabccc
ccbcabca
ccbbbabb
acaacbbb
abccaccb
acbcbacc
acabbcba
bacccbac
abbbbcac
bccaaccb
bbacccca
bbbcabbc
bbacbbbc
aacbbccc
cbcacbac
bbbbabcc
ccbcbcaa
bbabbccb
acabccbc
bacbbcaa
bbacbbbc
bccccaab
accaccbb
abbcccac
cbcabcab
ccbbacac
baccabcc
bacaccbc
bbcaccca
cbbacacc
ccbbbaac
cbbabcca
ccbaabcc
ccbabacc
bccaacbc
cbbaaccc
acbbacba
cccaabbc
cacabcbc
cabcbcca
cbbcbaab
cabcaccb
abcabcbb
bacccbca
ccbacacb
acccbbac
bbacbbcb
bcbccaac
cabccacb
cbbaacba
acbcaabb
cbbaabcb
cbcbbabb
babbccac
bccccbaa
bbbcacba
accccabb
cbbbaacc
cbcbbabb
ccacbacb
acbacccb
cbacccab
cbcbbcaa
cbcbacca
caabbccb
bccaccab
abbccbba
abbcccca
caaccbbc
bacabccc
bccaccab
bcabaccc
ccacabbc
bbbcabcb
bbbccabb
caacccbb
ccacbbca
abbcccca
ccabaabb
aacccbcb
cbcbcaac
ccccabba
cbcccaab
bcabaccc
cbccaabc
bccbacac
cbbbcabb
aacbcbba
acbacbcc
caacbccb
bbcaccca
cccacbba
bcaacbcc
bcaacbbc
cbcccaab
bcccacba
abbccacc
accbcacb
ccbbacca
abcbbcca
aaabbcbc
bbbabccb
caccabcb
bccbbbab
accabccb
babccacc
bcaccbac
babbccca
ccacbbac
cababccc
ccabcbac
bbcacacc
cccbaabb
abcabccc
acacbbcc
bacbccac
cacbccab
acacbccb
bcbcacca
abbcbbbc
acbccbca
acbaacbb
cbbbcaaa
abaccbba
cabcbbbb
babccbbb
bcaabccc
ccbccbaa
bccccbaa
bcbcbaab
bcacbacc
abcbaccc
bbccccaa
acccbabc
bbccacac
cbabccca
bacabccc
abbacbbc
cbccacba
babcaccc
cbbaccca
bcaccbca
bcaacbcc
cbccaabc
ccabccba
cacaccbb
baacbccb
acacccbb
bcaaccbc
ccccabab
cccabbac
ccbbbabb
bbbacaca
cbcacacb
cabbcabb
accbabcc
bcbbaaca
acbacccb
abbbcabc
bacaccbc
abccbcba
babbcaca
cbcccaab
baccabcc
cccaabbc
cbacabbb
ccacbbac
abbbacca
acbabbcb
bbacbcba
cbbcbabb
caccabbb
bcbccaca
aabcbcab
acccacbb
bcbbcabb
cbcabacc
acbbcaba
bbcaccac
ccbcabac
ccaccabb
cccacbab
bbcaccca
bbaacbbc
bbabcacb
abacbccc
cabcabcc
caccacbb
acbabccc
baacbbbc
ccbccaab
accbcbac
cccbabca
cacccbba
cbcabcab
cbbbcaba
bcbaccca
abcaccbc
abacccbc
bcccacab
bbccbbba
aaccccbb
aabccbcc
bbabbccb
cccbcbaa
caacbbcb
baaccbcc
cbccacab
aabcbccc
cabcacbc
aabcbccc
cbacbcac
aacccbbc
ccccabab
bcaacccb
cbbaccca
bbaacccc
accbcbac
bbbabcbc
bbacccca
accacbbc
aaabccbb
bbcbcbba
acbcbacc
cbccacab
cbabbacc
abcacccb
bccaaccb
acccabcb
bcbbaaac
acccbabc
ccaccbab
ccbcabca
ccbcaacb
cbcbccaa
babcbacb
babcbcab
cabaccbc
bbccabbb
caccabbb
acbcbcac
bccbbabb
abbccacc
bccacabc
cbacbcca
bbcbbacb
accbccab
cacbcbca
ccacacbb
cbbbcabb
cccacabb

输出:

4253348

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int main()
{
    time_t START=clock();
    freopen("/home/lu/鏂囨。/绗竷灞婃澀宸炲喅璧涘笀璧勫煿璁細璧勬枡/甯堣祫鍩硅浼?2016-鏉窞/寰€灞婄湡棰?2015鐪熼-瑙i鎬濊矾-婧愮爜/鍐宠禌/C++澶уB缁?4/娴嬭瘎鐢ㄤ緥/in4.txt","r",stdin);
    string s;
    cin>>s;
    map<string,int>mp;
    for(int i=7;i<s.size();++i)
    {
       string buf;
       buf.assign(s.begin()+i-7,s.begin()+i+1);
       sort(buf.begin(),buf.end());
       ++mp[buf];
    }
    int n;
    cin>>n;
    int sum=0;
    while(n--)
    {
        cin>>s;
        sort(s.begin(),s.end());
        if(mp.find(s)!=mp.end())
            sum+=mp[s];
    }
    cout<<sum<<endl;
    cout<<"cost time:"<<(double)(clock()-START)/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}



标题:居民集会


蓝桥村的居民都生活在一条公路的边上,公路的长度为L,每户家庭的位置都用这户家庭到公路的起点的距离来计算,第i户家庭距起点的距离为di。


每年,蓝桥村都要举行一次集会。今年,由于村里的人口太多,村委会决定要在4个地方举行集会,其中3个位于公路中间,1个位最公路的终点。


已知每户家庭都会向着远离公路起点的方向去参加集会,参加集会的路程开销为家庭内的人数ti与距离的乘积。


给定每户家庭的位置di和人数ti,请为村委会寻找最好的集会举办地:p1, p2, p3, p4 (p1<=p2<=p3<=p4=L),使得村内所有人的路程开销和最小。


【输入格式】
输入的第一行包含两个整数n, L,分别表示蓝桥村的家庭数和公路长度。
接下来n行,每行两个整数di, ti,分别表示第i户家庭距离公路起点的距离和家庭中的人数。


【输出格式】
输出一行,包含一个整数,表示村内所有人路程的开销和。
【样例输入】
6 10
1 3
2 2
4 5
5 20
6 5
8 7
【样例输出】
18
【样例说明】
在距起点2, 5, 8, 10这4个地方集会,6个家庭需要的走的距离分别为1, 0, 1, 0, 2, 0,总的路程开销为1*3+0*2+1*5+0*20+2*5+0*7=18。


【数据规模与约定】
对于10%的评测数据,1<=n<=300。
对于30%的评测数据,1<=n<=2000,1<=L<=10000,0<=di<=L,di<=di+1,0<=ti<=20。
对于100%的评测数据,1<=n<=100000,1<=L<=1000000,0<=di<=L,di<=di+1,0<=ti<=1000000。




资源约定:
峰值内存消耗 < 512M
CPU消耗  < 5000ms




请严格按要求输出,不要画蛇添足地打印类似:“请您输入...” 的多余内容。


所有代码放在同一个源文件中,调试通过后,拷贝提交该源码。


注意: main函数需要返回0
注意: 只使用ANSI C/ANSI C++ 标准,不要调用依赖于编译环境或操作系统的特殊函数。
注意: 所有依赖的函数必须明确地在源文件中 #include <xxx>, 不能通过工程设置而省略常用头文件。


提交时,注意选择所期望的编译器类型。




#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<string>
#include<vector>
using namespace std;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ll long long

struct P
{
    int n,dis;
    ll sum;
    bool kh;
};

P*ini(vector<int>&v,int n,int l)
{
    P*p=new P[n+1];
    for(int i=0;i<n;++i)
    {
        p[i].kh=false;
        cin>>p[i].dis>>p[i].n;
    }
    p[0].sum=p[0].n;
    for(int i=1;i<n+1;++i)
        p[i].sum=p[i-1].sum+p[i].n;
    if(p[n-1].dis==l)
    {
        p[n-1].kh=true;
        p[n-1].n=0;
        v.push_back(n-1);
    }
    v.push_back(n);
    p[n].kh=true;
    p[n].dis=l;
    p[n].n=0;
    return p;
}

void built_khd(vector<int>&v,P*p,int n)
{
    int index_khd=0;
    int khd=v[index_khd++];
    int maxcost_index=-1;
    ll maxcost=-1;
    for(int i=0;i<n;++i)
    {
        if(khd<i)
            khd=v[index_khd++];
        ll cost=p[khd].dis-p[i].dis;
        cost*=p[i].sum;
        if(cost>maxcost)
        {
            maxcost=cost;
            maxcost_index=i;
        }
    }
    v.insert(upper_bound(v.begin(),v.end(),maxcost_index),maxcost_index);
    p[maxcost_index].kh=true;
    p[maxcost_index].n=0;
    for(int i=0;i<n;++i)
        if(p[i].kh)
            p[i].sum=0;
        else
            if(i>0)
                p[i].sum=p[i].n+p[i-1].sum;
            else
                p[i].sum=p[i].n;
}

ll work(int n,int l)
{
   vector<int>v;
   P*p=ini(v,n,l);
   for(int i=0;i<3;++i)
       built_khd(v,p,n);
   int index=0;
   int khd=v[index++];
   ll cost=0;
   for(int i=0;i<n;++i)
   {
       while(p[khd].dis<p[i].dis)
           khd=v[index++];
       cost+=(ll)(p[khd].dis-p[i].dis)*p[i].n;
   }
   return cost;
}

int main()
{
    time_t START=clock();

    freopen("/home/lu/鏂囨。/绗竷灞婃澀宸炲喅璧涘笀璧勫煿璁細璧勬枡/甯堣祫鍩硅浼?2016-鏉窞/寰€灞婄湡棰?2015鐪熼-瑙i鎬濊矾-婧愮爜/鍐宠禌/C++澶уB缁?5/娴嬭瘎鐢ㄤ緥/in1.txt","r",stdin);

    int n,l;
    cin>>n>>l;
    if(n<4)
    {
        cout<<"0"<<endl;
        return 0;
    }
    cout<<work(n,l)<<endl;

    cout<<"cost time:"<<(double)(clock()-START)/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}





标题:模型染色


在电影《超能陆战队》中,小宏可以使用他的微型机器人组合成各种各样的形状。
现在他用他的微型机器人拼成了一个大玩具给小朋友们玩。为了更加美观,他决定给玩具染色。


小宏的玩具由n个球型的端点和m段连接这些端点之间的边组成。下图给出了一个由5个球型端点和4条边组成的玩具,看上去很像一个分子的球棍模型。
 
由于小宏的微型机器人很灵活,这些球型端点可以在空间中任意移动,同时连接相邻两个球型端点的边可以任意的伸缩,这样一个玩具可以变换出不同的形状。在变换的过程中,边不会增加,也不会减少。
小宏想给他的玩具染上不超过k种颜色,这样玩具看上去会不一样。如果通过变换可以使得玩具变成完全相同的颜色模式,则认为是本质相同的染色。现在小宏想知道,可能有多少种本质不同的染色。


【输入格式】
输入的第一行包含三个整数n, m, k,
分别表示小宏的玩具上的端点数、边数和小宏可能使用的颜色数。端点从1到n编号。
接下来m行每行两个整数a, b,表示第a个端点和第b个端点之间有一条边。输入保证不会出现两条相同的边。


【输出格式】
输出一行,表示本质不同的染色的方案数。由于方案数可能很多,请输入方案数除10007的余数。


【样例输入】
3 2 2
1 2
3 2
【样例输出】
6
【样例说明】
令(a, b, c)表示第一个端点染成a,第二个端点染成b,第三个端点染成c,则下面6种本质不同的染色:(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2), (2, 1, 2), (2, 2, 2)。
而(2, 1, 1)与(1, 1, 2)是本质相同的,(2, 2, 1)与(1, 2, 2)是本质相同的。


【数据规模与约定】
对于20%的评测数据,1<=n<=5, 1<=k<=2。
对于50%的评测数据,1<=n<=10, 1<=k<=8。
对于100%的评测数据,1<=n<=10, 1<=m<=45, 1<=k<=30。


资源约定:
峰值内存消耗 < 512M
CPU消耗  < 5000ms




请严格按要求输出,不要画蛇添足地打印类似:“请您输入...” 的多余内容。


所有代码放在同一个源文件中,调试通过后,拷贝提交该源码。


注意: main函数需要返回0
注意: 只使用ANSI C/ANSI C++ 标准,不要调用依赖于编译环境或操作系统的特殊函数。
注意: 所有依赖的函数必须明确地在源文件中 #include <xxx>, 不能通过工程设置而省略常用头文件。


提交时,注意选择所期望的编译器类型。






你可能感兴趣的:(2015蓝桥真题 (B组国赛))