A8919 | XOR and OR
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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 $10^{6}$ .
It is guaranteed that the given strings only consist of characters "0" and "1". The strings are not empty, their length doesn't exceed $10^{6}$ .
输出格式
Print "YES" if $a$ can be transformed into $b$ , otherwise print "NO". Please do not print the quotes.
输入输出样例
输入 #1
11 10
输出 #1
YES
输入 #2
1 01
输出 #2
NO
输入 #3
000 101
输出 #3
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted