欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1951A.Dual Trigger
Dual Trigger
Ngọt - LẦN CUỐI (đi bên em xót xa người ơi)ඞ
There are lamps numbered to lined up in a row, initially turned off. You can perform the following operation any number of times (possibly zero):
- Choose two non-adjacent lamps that are currently turned off, then turn them on.
Determine whether you can reach configuration , where means the -th lamp is turned on, and otherwise.
Only lamp and are adjacent for all . Note that lamp and are not adjacent when .
Input
Each test contains multiple test cases. The first line contains an integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains an integer () — the number of lamps.
The second line of each test case contains a binary string of size — the final desired configuration.
Output
For each test case, print on one line "YES" if we can reach the configuration via applying the given operation any number of times. Otherwise, print "NO".
Note
In the first test case, the sequence of operation could have been as follows (note that initially is all zero): 0000000000} \to \mathtt{\color{red}{1}0000000\color{red}{1}0} \to \mathtt{1\color{red}{1}00000\color{red}{1}10} \to \mathtt{110\color{red}{1}0\color{red}{1}0110.
In the third test case, we don't have to do any operation.
In the fourth test case, we cannot do any operation, but we need the first lamp to be on. Therefore, it is impossible to achieve the desired state.
Samples
5
10
1101010110
10
1001001110
6
000000
1
1
12
111111111111
YES
NO
YES
NO
YES
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |