282C.md (1841B)
1 Source: https://codeforces.com/problemset/problem/282/C 2 3 C. XOR and OR 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 The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. 22 23 A Bitlandish string is a string made only of characters "0" and "1". 24 25 BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish string *a*, and applies several (possibly zero) operations to it. In one operation the mayor may take any two adjacent characters of a string, define one of them as *x* and the other one as *y*. Then he calculates two values *p* and *q*: *p* = *x* *xor* *y*, *q* = *x* *or* *y*. Then he replaces one of the two taken characters by *p* and the other one by *q*. 26 27 The *xor* operation means the bitwise excluding OR operation. The *or* operation is the bitwise OR operation. 28 29 So for example one operation can transform string 11 to string 10 or to string 01. String 1 cannot be transformed into any other string. 30 31 You've got two Bitlandish strings *a* and *b*. Your task is to check if it is possible for BitHaval to transform string *a* to string *b* in several (possibly zero) described operations. 32 33 Input 34 35 The first line contains Bitlandish string *a*, the second line contains Bitlandish string *b*. The strings can have different lengths. 36 37 It is guaranteed that the given strings only consist of characters "0" and "1". The strings are not empty, their length doesn't exceed 106. 38 39 Output 40 41 Print "YES" if *a* can be transformed into *b*, otherwise print "NO". Please do not print the quotes. 42 43 Examples 44 45 Input 46 47 ``` 48 11 49 10 50 ``` 51 52 Output 53 54 ``` 55 YES 56 ``` 57 58 Input 59 60 ``` 61 1 62 01 63 ``` 64 65 Output 66 67 ``` 68 NO 69 ``` 70 71 Input 72 73 ``` 74 000 75 101 76 ``` 77 78 Output 79 80 ``` 81 NO 82 ```