欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2092B.Lady Bug
Lady Bug
As soon as Dasha Purova crossed the border of France, the villain Markaron kidnapped her and placed her in a prison under his large castle. Fortunately, the wonderful Lady Bug, upon hearing the news about Dasha, immediately ran to save her in Markaron's castle. However, to get there, she needs to crack a complex password.
The password consists of two bit strings and , each of which has a length of . In one operation, Lady Bug can choose any index and perform one of the following actions:
- swap(, ) (swap the values of and ), or
- swap(, ) (swap the values of and ).
Lady Bug can perform any number of operations. The password is considered cracked if she can ensure that the first string consists only of zeros. Help her understand whether or not she will be able to save the unfortunate Dasha.
Input
Each test consists of several test cases. The first line of the input data contains one integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer () — the length of the bit strings of the password.
The next two lines contain the bit strings of length , and , which represent the password. Each of the strings contains only the characters 0 and '1'.
It is guaranteed that the sum of across all test cases does not exceed .
Output
For each test case, output "YES" if Lady Bug can crack the password after any number of operations; otherwise, output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
Note
In the first test case, the string immediately consists only of zeros.
In the second test case, a possible sequence of operations is:
-
swap
0{\color{red}{1}}0001{\color{red}{0}}10111 -
swap
000{\color{red}{0}}011101{\color{red}{1}}1 -
swap
000{\color{red}{1}}0111{\color{red}{0}}101 -
swap
00000{\color{red}{1}}1111{\color{red}{0}}1
Samples
4
3
000
000
6
010001
010111
5
10000
01010
2
11
00
YES
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |