186A.md (1634B)
1 Source: https://codeforces.com/problemset/problem/186/A 2 3 A. Comparing Strings 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 stdin 16 17 output 18 19 stdout 20 21 Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters. 22 23 Dwarf Misha has already chosen the subject for his thesis: determining by two dwarven genomes, whether they belong to the same race. Two dwarves belong to the same race if we can swap two characters in the first dwarf's genome and get the second dwarf's genome as a result. Help Dwarf Misha and find out whether two gnomes belong to the same race or not. 24 25 Input 26 27 The first line contains the first dwarf's genome: a non-empty string, consisting of lowercase Latin letters. 28 29 The second line contains the second dwarf's genome: a non-empty string, consisting of lowercase Latin letters. 30 31 The number of letters in each genome doesn't exceed 105. It is guaranteed that the strings that correspond to the genomes are different. The given genomes may have different length. 32 33 Output 34 35 Print "YES", if the dwarves belong to the same race. Otherwise, print "NO". 36 37 Examples 38 39 Input 40 41 ``` 42 ab 43 ba 44 ``` 45 46 Output 47 48 ``` 49 YES 50 ``` 51 52 Input 53 54 ``` 55 aa 56 ab 57 ``` 58 59 Output 60 61 ``` 62 NO 63 ``` 64 65 Note 66 67 * First example: you can simply swap two letters in string "ab". So we get "ba". 68 * Second example: we can't change string "aa" into string "ab", because "aa" does not contain letter "b".