Baltic Olympiad in Informatics: 2014 Day 1, Problem 2
Three friends like to play the following game. The first friend chooses a string . Then the second friend constructs a new string that consists of two copies of the string . Finally, the third friend inserts one letter at the beginning, the end or somewhere inside the string , thereby creating a string .
Given the string , your task is to reconstruct the original string .
Constraints
Subtask 1 [35%]
Subtask 2 [65%]
No additional constraints.
Input Specification
The only line of input contains the string , which consists of uppercase English letters.
Output Specification
Your program should print the original string . However, there are two exceptions:
- If the final string could not have been created using the above procedure, you should
print
NOT POSSIBLE
. - If the original string is not unique, you should print
NOT UNIQUE
.
Sample Input 1
ABXCABC
Sample Output 1
ABC
Sample Input 2
ABCDEF
Sample Output 2
NOT POSSIBLE
Sample Input 3
ABABABABA
Sample Output 3
NOT UNIQUE
Comments