CF126B.Password
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s , carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the temple and read the string aloud. However, nothing happened. Then Asterix supposed that a password is some substring t of the string s .
Prefix supposed that the substring t is the beginning of the string s ; Suffix supposed that the substring t should be the end of the string s ; and Obelix supposed that t should be located somewhere inside the string s , that is, t is neither its beginning, nor its end.
Asterix chose the substring t so as to please all his companions. Besides, from all acceptable variants Asterix chose the longest one (as Asterix loves long strings). When Asterix read the substring t aloud, the temple doors opened.
You know the string s . Find the substring t or determine that such substring does not exist and all that's been written above is just a nice legend.
Asterix、Obelix 和他们的临时伙伴 Suffix 和 Prefix 终于找到了和谐神殿。然而,神殿的大门紧紧地锁着,就连欧比也无法打开。
过了一会儿,他们在寺庙大门下面的一块石头上发现了一个字符串 s 。亚力认为这是打开神庙的密码,于是大声念了出来。然而,什么也没发生。然后,亚力认为密码是 s 的子串 t 。
前缀认为,子串 t 是字符串 s 的开头;后缀认为,子串 t 应该是字符串 s 的结尾;而后缀认为, t 应该位于字符串 s 的某处,也就是说, t 既不是它的开头,也不是它的结尾。
为了让所有同伴满意,Asterix 选择了 t 这个子串。此外,在所有可接受的变体中,Asterix 选择了最长的一个(因为 Asterix 喜欢长串)。当 Asterix 大声读出 t 子串时,神殿的大门打开了。
你知道字符串 s 。找出 t 的子串,或者确定这样的子串并不存在,上面所写的只是一个美丽的传说。
输入格式
You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters.
输入
我们会给你一个字符串 s ,其长度从 1 到 106 (含)不等,由小的拉丁字母组成。
输出格式
Print the string t . If a suitable t string does not exist, then print "Just a legend" without the quotes.
输出
打印字符串 t 。如果不存在合适的 t 字符串,则打印"只是一个图例",去掉引号。
输入输出样例
输入#1
fixprefixsuffix
输出#1
fix
输入#2
abcdabc
输出#2
Just a legend