CF282C.XOR and OR
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
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.
The xor operation means the bitwise excluding OR operation. The or operation is the bitwise OR operation.
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.
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.
Bitland 的居民非常古怪,他们做任何事情的方式都与众不同。他们拥有自己独特的字母表,因此对“字符串”的定义也与其他地方不同。
Bitland 字符串仅由字符 "0" 和 "1" 构成。
BitHaval(Bitland 的市长)非常喜欢玩 Bitland 字符串。他取某个 Bitland 字符串 a,并对其执行若干次(可能为零次)如下操作:在一次操作中,市长可任选字符串中两个相邻的字符,将其中一个记为 x,另一个记为 y;然后计算两个值 p 和 q:p=x xor y,q=x or y;最后,他将这两个被选中的字符之一替换为 p,另一个替换为 q。
其中,“xor” 表示按位异或(exclusive OR)运算,“or” 表示按位或(OR)运算。
例如,一次操作可将字符串 11 变为 10 或 01;而字符串 1 则无法变为任何其他字符串。
现在你得到了两个 Bitland 字符串 a 和 b。你的任务是判断:BitHaval 是否能通过若干次(可能为零次)上述操作,将字符串 a 变为字符串 b。
输入格式
The first line contains Bitlandish string a, the second line contains Bitlandish string b. The strings can have different lengths.
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.
第一行包含 Bitlandish 字符串 a,第二行包含 Bitlandish 字符串 b。这两个字符串的长度可能不同。
保证所给字符串仅由字符 "0" 和 "1" 组成。字符串非空,且长度不超过 106。
输出格式
Print "YES" if a can be transformed into b, otherwise print "NO". Please do not print the quotes.
如果 a 可以转换为 b,则输出 YES,否则输出 NO。请不要输出引号。
输入输出样例
输入#1
11 10
输出#1
YES
输入#2
1 01
输出#2
NO
输入#3
000 101
输出#3
NO
输入解题思路,AI测评打分。不知道怎么写?