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 ss of length nn and an integer kk.

Arseniy can make an unlimited number of moves. In one move, he can choose an integer ii (1≤i≤n−k1 \le i \le n - k) and invert the characters at positions ii and i+ki + k, that is, change 00 to 11 and 11 to 00.

For example, if s=10110s = 10110 and k=2k = 2, then by choosing i=2i = 2, Arseniy inverts the characters at positions 22 and 44: [10110→11100][ 10110 \rightarrow 11100 ]

Arseniy wants to get the main prize — 1 000 0001\,000\,000 tugriks. To do this, he needs to make the entire string ss equal to zero.

Help Arseniy determine whether he can get his prize, or if he will have to return to Omsk with nothing.

假期期间,叶戈尔来到喀山拜访他的朋友达比尔。出于无聊,达比尔和叶戈尔想出了一个新生意点子:自己制作一档电视节目。

该节目的形式非常简单:每期节目邀请一位嘉宾,并与嘉宾玩一个关于二进制字符串的游戏。

在本期节目中,叶戈尔和达比尔邀请了鄂木斯克的头号名人——阿尔谢尼(又称 MAKAN)。游戏选定一个长度为 nn 的二进制字符串 ss 和一个整数 kk。

阿尔谢尼可以进行任意多次操作。每次操作中,他可以选择一个整数 ii(满足 1≤i≤n−k1 \le i \le n - k),并将位置 ii 和 i+ki + k 上的字符取反,即把 00 变为 11,把 11 变为 00。

例如,若 s=10110s = 10110 且 k=2k = 2,则当选择 i=2i = 2 时,阿尔谢尼将位置 22 和 44 上的字符取反:[10110→11100][ 10110 \rightarrow 11100 ]

阿尔谢尼希望赢得大奖——1,000,000 图格里克。为此,他需要将整个字符串 ss 变为全 00。

请帮助阿尔谢尼判断他是否能赢得奖金,还是不得不空手返回鄂木斯克。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers nn and kk (1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5).

The second line of each test case contains a binary string ss of length nn.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 表示测试用例的数量。

每个测试用例的第一行包含两个整数 nn 和 kk(1≤k≤n≤2⋅1051 \le k \le n \le 2 \cdot 10^5)。

每个测试用例的第二行包含一个长度为 nn 的二进制字符串 ss。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

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测评打分。不知道怎么写?

首页