CF126B.Password

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

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.

阿斯特里克斯、奥贝利克斯,以及他们暂时的伙伴后缀(Suffix)和前缀(Prefix),终于找到了和谐神庙。然而,神庙的大门被牢牢锁住,甚至连奥贝利克斯都未能将其打开。

稍后,他们在神庙大门下方的一块岩石上发现了一串字符串 $ s $。阿斯特里克斯猜测这便是开启神庙的密码,并将该字符串大声读出。然而,什么也没有发生。接着,阿斯特里克斯推测密码应为字符串 $ s $ 的某个子串 $ t $。

前缀(Prefix)认为子串 $ t $ 应当是字符串 $ s $ 的前缀;后缀(Suffix)认为子串 $ t $ 应当是字符串 $ s $ 的后缀;而奥贝利克斯则认为 $ t $ 应当出现在字符串 $ s $ 的内部,即 $ t $ 既不是 $ s $ 的前缀,也不是 $ s $ 的后缀。

阿斯特里克斯选择子串 $ t $ 时,力求满足所有同伴的要求。此外,在所有满足条件的候选子串中,阿斯特里克斯选择了最长的一个(因为阿斯特里克斯钟爱长字符串)。当他将子串 $ t $ 大声读出时,神庙的大门打开了。

已知字符串 $ s $,请找出满足上述条件的子串 $ t $;若不存在这样的子串,则判定前述全部描述仅是一个美好的传说。

输入格式

You are given the string s whose length can vary from 1 to 106 (inclusive), consisting of small Latin letters.

给你一个字符串 ss,其长度在 11 到 10610^6(含)之间,且仅由小写拉丁字母组成。

输出格式

Print the string t. If a suitable t string does not exist, then print "Just a legend" without the quotes.

输出字符串 tt。如果不存在合适的字符串 tt,则输出 "Just a legend"(不带引号)。

输入输出样例

  • 输入#1

    fixprefixsuffix

    输出#1

    fix
  • 输入#2

    abcdabc

    输出#2

    Just a legend

输入解题思路,AI测评打分。不知道怎么写?

首页