C1. Message Transmission Error (easy version) time limit per test2 seconds memory limit…
- User
C1. Message Transmission Error (easy version) time limit per test2 seconds memory limit per test256 megabytes This is a simplified version of the problem. It differs from the difficult one only in its constraints.
At the Berland State University, the local network between servers does not always operate without errors. When transmitting two identical messages consecutively, an error may occur, resulting in the two messages merging into one. In this merging, the end of the first message coincides with the beginning of the second. Of course, the merging can only occur at identical characters. The length of the merging must be a positive number less than the length of the message text.
For example, when transmitting two messages "abrakadabra" consecutively, it is possible that it will be transmitted with the described type of error, resulting in a message like "abrakadabrabrakadabra" or "abrakadabrakadabra' (in the first case, the merging occurred at one character, and in the second case, at four).
Given the received message t, determine if it is possible that this is the result of an error of the described type in the operation of the local network, and if so, determine a possible value of s.
A situation where two messages completely overlap each other should not be considered an error. For example, if the received message is "abcd", it should be considered that there is no error in it. Similarly, simply appending one message after another is not a sign of an error. For instance, if the received message is "abcabc", it should also be considered that there is no error in it.
Input The input consists of a single non-empty string t, consisting of lowercase letters of the Latin alphabet. The length of the string t does not exceed 100 characters.
Output If the message t cannot contain an error, output "NO" (without quotes) in a single line of output.
Otherwise, in the first line, output "YES" (without quotes), and in the next line, output the string s — a possible message that could have led to the error. If there are multiple possible answers, any of them is acceptable.
Examples inputCopy abrakadabrabrakadabra outputCopy YES abrakadabra inputCopy acacacaca outputCopy YES acaca inputCopy abcabc outputCopy NO inputCopy abababab outputCopy YES ababab inputCopy tatbt outputCopy NO Note In the second example, a suitable answer could also be the string "acacaca".
Testing Round 19 (Div. 3) Finished Practice Add to favourites → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.
- Assistant
To solve this problem, we'll attempt to reconstruct possible original messages
sand determine whether the received messagetcould be the result of the described transmission error.Approach:
-
Fundamental Observations:
- The error involves overlapping two identical messages at a certain position , where the end of the first overlaps with the beginning of the second .
-