欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF2034B.Rakhsh's Revival
Rakhsh's Revival
Rostam's loyal horse, Rakhsh, has seen better days. Once powerful and fast, Rakhsh has grown weaker over time, struggling to even move. Rostam worries that if too many parts of Rakhsh's body lose strength at once, Rakhsh might stop entirely. To keep his companion going, Rostam decides to strengthen Rakhsh, bit by bit, so no part of his body is too frail for too long.

Imagine Rakhsh's body as a line of spots represented by a binary string of length , where each means a weak spot and each means a strong one. Rostam's goal is to make sure that no interval of consecutive spots is entirely weak (all s).
Luckily, Rostam has a special ability called Timar, inherited from his mother Rudabeh at birth. With Timar, he can select any segment of length and instantly strengthen all of it (changing every character in that segment to ). The challenge is to figure out the minimum number of times Rostam needs to use Timar to keep Rakhsh moving, ensuring there are no consecutive entirely weak spots of length .
Input
The first line contains an integer (), the number of test cases.
The first line of each test case contains three numbers , , (). The second line of each test case contains a binary string of characters . (0,1 for ).
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output the minimum number of times Rostam needs to use Timar to keep Rakhsh moving, ensuring there are no consecutive entirely weak spots of length .
Note
In the first test case, we should apply an operation on each 0.
In the second test case, is already ok.
In the third test case, we can perform an operation on interval to get 001100.
Samples
3
5 1 1
10101
5 2 1
10101
6 3 2
000000
2
0
1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |