CF2236B.Tatar TV Show
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
During the holidays, Egor came to visit his friend Dabir in the city of Kazan. Out of boredom, Dabir and Egor came up with a new business idea: to make their own TV show.
The format of the show is very simple: in each episode they invite a guest and play a game with them on a binary string.
In today's episode, Egor and Dabir invited Arseniy (aka MAKAN) — the main celebrity of Omsk. For the game, they chose a binary string s of length n and an integer k.
Arseniy can make an unlimited number of moves. In one move, he can choose an integer i (1≤i≤n−k) and invert the characters at positions i and i+k, that is, change 0 to 1 and 1 to 0.
For example, if s=10110 and k=2, then by choosing i=2, Arseniy inverts the characters at positions 2 and 4: [10110→11100]
Arseniy wants to get the main prize — 1000000 tugriks. To do this, he needs to make the entire string s equal to zero.
Help Arseniy determine whether he can get his prize, or if he will have to return to Omsk with nothing.
假期期间,叶戈尔来到喀山拜访他的朋友达比尔。出于无聊,达比尔和叶戈尔想出了一个新生意点子:自己制作一档电视节目。
该节目的形式非常简单:每期节目邀请一位嘉宾,并与嘉宾玩一个关于二进制字符串的游戏。
在本期节目中,叶戈尔和达比尔邀请了鄂木斯克的头号名人——阿尔谢尼(又称 MAKAN)。游戏选定一个长度为 n 的二进制字符串 s 和一个整数 k。
阿尔谢尼可以进行任意多次操作。每次操作中,他可以选择一个整数 i(满足 1≤i≤n−k),并将位置 i 和 i+k 上的字符取反,即把 0 变为 1,把 1 变为 0。
例如,若 s=10110 且 k=2,则当选择 i=2 时,阿尔谢尼将位置 2 和 4 上的字符取反:[10110→11100]
阿尔谢尼希望赢得大奖——1,000,000 图格里克。为此,他需要将整个字符串 s 变为全 0。
请帮助阿尔谢尼判断他是否能赢得奖金,还是不得不空手返回鄂木斯克。
输入格式
The first line contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains two integers n and k (1≤k≤n≤2⋅105).
The second line of each test case contains a binary string s of length n.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104)—— 表示测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 k(1≤k≤n≤2⋅105)。
每个测试用例的第二行包含一个长度为 n 的二进制字符串 s。
保证所有测试用例的 n 之和不超过 2⋅105。
输出格式
For each test case, output "YES" if Arseniy can make the string entirely zero, and "NO" otherwise.
You can output "YES" and "NO" in any case (for example, "yES", "yes", and "Yes" will be accepted).
对于每个测试用例,如果阿森伊能使字符串全部变为零,则输出 “YES”,否则输出 “NO”。
你可以以任意大小写形式输出 “YES” 和 “NO”(例如,“yES”、“yes” 和 “Yes” 均可被接受)。
输入输出样例
输入#1
5 4 2 1010 3 2 111 3 3 111 3 1 110 1 1 1
输出#1
YES NO NO YES NO
说明/提示
null
输入解题思路,AI测评打分。不知道怎么写?