#P16887. [GKS 2022 #E] Matching Palindrome
[GKS 2022 #E] Matching Palindrome
Problem Description
You are given a palindrome string of length consisting of only lowercase letters of the English alphabet. Find the shortest non-empty palindrome string such that concatenated with forms a palindrome. Formally, the string forms a palindrome.
Input Format
The first line of the input gives the number of test cases, . test cases follow. Each test case consists of lines. The first line of each test case contains an integer denoting the length of the string . The second line of each test case contains a palindrome string of length .
Output Format
For each test case, output one line containing Case #: , where is the test case number starting from and is the non-empty palindrome string as described above.
3
4
abba
4
cccc
6
cdccdc
Case #1: abba
Case #2: c
Case #3: cdc
Hint
In Case , the shortest palindrome string is abba such that the concatenation is abbaabba, which is a palindrome.
In Case , the shortest palindrome string is c such that the concatenation is ccccc, which is a palindrome.
In Case , the shortest palindrome string is cdc such that the concatenation is cdccdccdc, which is a palindrome.
Limits
.
String is a palindrome consisting of only lowercase letters of the English alphabet.
Test Set 1
.
Test Set 2
.