Write in C Language Spilitology Yosef is a peculiar fellow. He introduced the idea to study a string by splitting it into two, and he called it Splitology. Why split a string? We do not know. Didn’t we say that Yosef is a weird one? Yosef is interested in one particular type of string, a palindrome. A palindrome is a string that is the same for both forwards and backwards. Example of palindrome strings are “ada”, “taat”, and “radar”. On the other hand, string such as “taman” is not a palindrome; notice that “taman” becomes “namat” if read backwards and it’s not the same as “taman”. As the idea of Splitology is still new, Yosef is investigating whether a string can be split into two non-empty strings such that each string is a palindrome. For example, the string “malamini” can be split into “malam” and “ini” while both of them are palindrome. Another example is “ababab”. It can be split into “aba” and “bab”, and both of them are palindrome. Note that “ababab” can also be split into another pair of palindrome strings, e.g., “ababa” and “b”, or “a” and “babab”. Gunawan, a friend of Yosef, is also a peculiar one. When he learned about Splitology, he asks Yosef whether the string “irvinganteng” can be split into two palindrome strings. The answer is of course no. It can be proven that such a string cannot be split into two palindrome strings. Given a string S, determine whether it can be split into two non-empty palindrome strings. If the answer is yes, then output two palindrome strings A and B where the concatenation of A and B is S, i.e. S = A + B.If the answer is no, then simply output “NO” without quotes. Input Input contains a string S in a line representing the given string. String S contains only lowercase alphabetical characters (a-z) and its length is between 2 and 500, inclusive. Output If S cannot be split into two palindrome strings, then output “NO” in a line. Otherwise, output two palindrome strings A and B in a line separated by a single space such that S = A + B. If there is more than one way to split S into two palindrome strings, you only need to output (any) one pair of A and B. Sample Input #1 malamini Sample Output #1 malam ini Sample Input #2 ababab Sample Output #2 aba bab Explanation for the sample input/output #2 Other outputs such as “a babab” (without quotes) or “ababa b” (without quotes) are also accepted. Sample Input #3 irvinganteng Sample Output #3 NO Sample Input #4 adakodok Sample Output #4 ada kodok Sample Input #5 mnonm Sample Output #5 NO Sample Input #6 se Sample Output #6 s e
Write in C Language
Spilitology
Yosef is a peculiar fellow. He introduced the idea to study a string by splitting it into two, and he called it Splitology. Why split a string? We do not know. Didn’t we say that Yosef is a weird one? Yosef is interested in one particular type of string, a palindrome. A palindrome is a string that is the same for both forwards and backwards. Example of palindrome strings are “ada”, “taat”, and “radar”. On the other hand, string such as “taman” is not a palindrome; notice that “taman” becomes “namat” if read backwards
and it’s not the same as “taman”. As the idea of Splitology is still new, Yosef is investigating whether a string can be split into two non-empty strings such that each string is a palindrome. For example, the string “malamini” can be split into “malam” and “ini” while both of them are palindrome. Another example is “ababab”. It can be split into “aba” and “bab”, and both of them are palindrome. Note that “ababab” can also be split into another pair of palindrome strings, e.g., “ababa” and “b”, or “a” and “babab”. Gunawan, a friend of Yosef, is also a peculiar one. When he learned about Splitology, he asks Yosef whether the string “irvinganteng” can be split into two palindrome strings. The answer is of course no. It can be proven that such a string cannot be split into two palindrome strings. Given a string S, determine whether it can be split into two non-empty palindrome strings. If the answer is yes, then output two palindrome strings A and B where the concatenation of A and B is S, i.e. S = A + B.If the answer is no, then simply output “NO” without quotes.
Input
Input contains a string S in a line representing the given string. String S contains only lowercase alphabetical characters (a-z) and its length is between 2 and 500, inclusive.
Output
If S cannot be split into two palindrome strings, then output “NO” in a line. Otherwise, output two palindrome strings A and B in a line separated by a single space such that S = A + B. If there is more than one way to split S into two palindrome strings, you only need to output (any) one pair of A and B.
Sample Input #1
malamini |
Sample Output #1
malam ini |
Sample Input #2
ababab |
Sample Output #2
aba bab |
Explanation for the sample input/output #2
Other outputs such as “a babab” (without quotes) or “ababa b” (without quotes) are also accepted.
Sample Input #3
irvinganteng |
Sample Output #3
NO |
Sample Input #4
adakodok |
Sample Output #4
ada kodok |
Sample Input #5
mnonm |
Sample Output #5
NO |
Sample Input #6
se |
Sample Output #6
s e |
Step by step
Solved in 2 steps with 6 images