求助,英语翻译,急!!!!!!!

142. Keyword

Time Limit: 2 sec, Memory Limit: 16 MB

Kevin has invented a new algorithm to crypt and decrypt messages, which he thinks is unbeatable. The algorithm uses a very large key-string, out of which a keyword is found out after applying the algorithm. Then, based on this keyword, the message is easily crypted or decrypted. So, if one would try to decrypt some messages crypted with this algorithm, then knowing the keyword would be enough. Someone has found out how the keyword is computed from the large key-string, but because he is not a very experienced computer programmer, he needs your help. The key-string consists of N characters from the set {'a','b'}. The keyword is the shortest non-empty string made up of the letters 'a' and 'b', which is not contained as a contiguous substring (also called subsequence) inside the key-string. It is possible that more than one such string exists, but the algorithm is designed in such a way that any of these strings can be used as a keyword. Given the key-string, your task is to find one keyword.

Input

The first line contains the integer number N, the number of characters inside the key-string (1 <= N <= 500 000). The next line contains N characters from the set {'a','b'} representing the string.

Output

The first line of output should contain the number of characters of the keyword. The second line should contain the keyword.

Sample Input

11
aabaaabbbab

Sample Output

4
aaaa

142 . 关键字时限: 2秒,内存限制: 至少16 MB凯文先后发明了一种新算法隐窝和解密的讯息,他认为是无法言喻的. 该算法利用一个非常大的关键字符串,其中一个关键字后发现,采用该算法. 然后,基于这个关键字,我们的信息很容易crypted或解密. 所以,如果你想尝试一些解密讯息crypted这种算法,然后知关键字那就足够了. 有人发现了如何使用关键字的计算方法是从大型关键字符串 但是,因为他不是一个非常有经验的计算机程序员,他需要你的帮助. 钥匙串由n个字符集( '一' , '二' ) . 关键字是最短的非空字符串组成的英文字母'一'和'二' , 这是不包含作为一个相连子(又称子)内键字符串. 它可能有一个以上的这类字符串存在, 但是该算法的设计是这样,这些人中的任何字符串可以作为关键字. 由于钥匙串,你的任务是要找到一个关键字. 输入的第一行包含整型数n , 数目字内键弦( 1 " =氮" = 500000 ) . 下一行包含了N字,从集合( ' , '乙' )代表字符串. 生产第一线的产量应包含的字符数的关键字. 二线应该包含关键字. 样品投入11 aabaaabbbab样本输出4对AAAA
阿拉伯文到英语 BETA朝鲜语到英语 BETA德语到法语德语到英语俄语到英语 BETA法语到德语法语到英语葡萄牙语到英语日语到英语 BETA西班牙语到英语意大利语到英语英语到阿拉伯文 BETA英语到朝鲜语 BETA英语到德语英语到俄语 BETA英语到法语英语到葡萄牙语英语到日语 BETA英语到西班牙语英语到意大利语英语到中文(繁体) BETA英语到中文(简体) BETA中文到英语 BETA中文(繁体到简体) BETA中文(简体到繁体) BETA
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-02-06
【翻译】

【每个测试点时间】1s.
【每个测试点内存】16384KB

Kevin发明了一个新的加密解密方法,他自以为这个方法很牛X.这个方法要使用非常大的key-string(关键字符串), 用来加密的关键字可以由这个key-string通过一定的规则得到.现在,以这个关键字为基础,加密解密就很容易了.所以,如果有人想破解这个算法加密的信息,只需要知道关键字就可以了.后来有人发现了这个key-string和加密算法,但是他不会写程序,所以只能请求你的帮助.
key-string由 N 字符组成,每个字符都属于集合{'a','b'}.那么关键字就是由 'a' 和 'b'组成的,不是key-string的子串的(也就是key-string不包含关键字)最短的字符串.可能存在多个这样的字符串,但是根据加密算法的特殊性质,任意一个这样的字符串都能满足要求.现在你知道 key-string,你的任务是求出一个关键字.

【输入】第一行是正整数 N,描述key-string的长度 (1 <= N <= 500 000).第二行有 N 个属于{'a','b'}的字符, 代表key-string的内容.
【输出】第一行输出关键字的长度,第二行输出关键字内容.

【样例输入】
11
aabaaabbbab
【样例输出】
4
aaaa
相似回答