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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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
Expert Solution
steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education