codeforces-scrape

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

545B.md (1617B)


      1 Source: https://codeforces.com/problemset/problem/545/B
      2 
      3 B. Equidistant String
      4 
      5 time limit per test
      6 
      7 1 second
      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 Little Susie loves strings. Today she calculates distances between them. As Susie is a small girl after all, her strings contain only digits zero and one. She uses the definition of Hamming distance:
     22 
     23 We will define the distance between two strings *s* and *t* of the same length consisting of digits zero and one as the number of positions *i*, such that *s**i* isn't equal to *t**i*.
     24 
     25 As besides everything else Susie loves symmetry, she wants to find for two strings *s* and *t* of length *n* such string *p* of length *n*, that the distance from *p* to *s* was equal to the distance from *p* to *t*.
     26 
     27 It's time for Susie to go to bed, help her find such string *p* or state that it is impossible.
     28 
     29 Input
     30 
     31 The first line contains string *s* of length *n*.
     32 
     33 The second line contains string *t* of length *n*.
     34 
     35 The length of string *n* is within range from 1 to 105. It is guaranteed that both strings contain only digits zero and one.
     36 
     37 Output
     38 
     39 Print a string of length *n*, consisting of digits zero and one, that meets the problem statement. If no such string exist, print on a single line "impossible" (without the quotes).
     40 
     41 If there are multiple possible answers, print any of them.
     42 
     43 Examples
     44 
     45 Input
     46 
     47 ```
     48 0001  
     49 1011
     50 ```
     51 
     52 Output
     53 
     54 ```
     55 0011
     56 ```
     57 
     58 Input
     59 
     60 ```
     61 000  
     62 111
     63 ```
     64 
     65 Output
     66 
     67 ```
     68 impossible
     69 ```
     70 
     71 Note
     72 
     73 In the first sample different answers are possible, namely — 0010, 0011, 0110, 0111, 1000, 1001, 1100, 1101.