oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

cute Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

cute.html

Problem Description

Coco the Monkey has a strange, unhealthy obsession with strings.

Coco the Monkey has suddenly decided that a string is cute, if it appears as a substring in another string S as a prefix, suffix and somewhere in the middle of string S (not as a prefix or suffix).

Please help Coco the Monkey find the longest string that is cute in string S.

Input

The only line of input will contain one string, S. S will contain only lowercase english alphabets and no other characters.

Output

Output a single string, the longest string that Coco the Monkey considers cute. If no such string exists, output -1.

Limits

Subtask 1 (33%): 1 ≤ | S | ≤ 1000.

Subtask 2 (67%): 1 ≤ | S | ≤ 1 000 000.

Subtask 3 (0%): Sample Testcases

Sample Testcase 1

Input

coconutcocothemonkeycoco

Output

coco

Tags

String Processing

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
133471s64MBMinimum
267651s64MBMinimum
3011s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o cute -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.