#P11276. Longest Border Construction

    ID: 13350 Type: Default 1000ms 256MiB

Longest Border Construction

Longest Border Construction

Given a string \( s \), find the shortest string \( t \) such that \( s \) is the longest border of \( t \). A string \( s \) is called a border of string \( t \) if and only if:

  • \( s \) is a prefix of \( t \).
  • \( s \) is a suffix of \( t \).
  • \( s \) is not equal to \( t \).

If there are multiple answers, output any one of them.

Note: A border of a string is a non-empty substring that is both a prefix and a suffix of the string and is not equal to the entire string.

inputFormat

The input consists of a single line containing the string \( s \). The string \( s \) is non-empty and consists of lowercase letters.

outputFormat

Output the shortest string \( t \) that satisfies the condition that \( s \) is its longest border.

sample

aba
ababa