codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

2010C1.md (2600B)


      1 Source: https://codeforces.com/problemset/problem/2010/C1
      2 
      3 C1. Message Transmission Error (easy version)
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 This is a simplified version of the problem. It differs from the difficult one only in its constraints.
     22 
     23 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.
     24 
     25 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).
     26 
     27 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*.
     28 
     29 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.
     30 
     31 Input
     32 
     33 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.
     34 
     35 Output
     36 
     37 If the message *t* cannot contain an error, output "NO" (without quotes) in a single line of output.
     38 
     39 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.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 abrakadabrabrakadabra
     47 ```
     48 
     49 Output
     50 
     51 ```
     52 YES  
     53 abrakadabra
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 acacacaca
     60 ```
     61 
     62 Output
     63 
     64 ```
     65 YES  
     66 acaca
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 abcabc
     73 ```
     74 
     75 Output
     76 
     77 ```
     78 NO
     79 ```
     80 
     81 Input
     82 
     83 ```
     84 abababab
     85 ```
     86 
     87 Output
     88 
     89 ```
     90 YES  
     91 ababab
     92 ```
     93 
     94 Input
     95 
     96 ```
     97 tatbt
     98 ```
     99 
    100 Output
    101 
    102 ```
    103 NO
    104 ```
    105 
    106 Note
    107 
    108 In the second example, a suitable answer could also be the string "acacaca".