CF1221E.Game With String

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alice and Bob play a game. Initially they have a string s1,s2,…,sns_1, s_2, \dots, s_n, consisting of only characters . and X. They take alternating turns, and Alice is moving first. During each turn, the player has to select a contiguous substring consisting only of characters . and replaces each of them with X. Alice must select a substing of length aa, and Bob must select a substring of length bb. It is guaranteed that a>ba \gt b.

For example, if s=s = ...X.. and a=3a = 3, b=2b = 2, then after Alice's move string can turn only into XXXX... And if it's Bob's turn and the string s=s = ...X.., then after Bob's move the string can turn into XX.X.., .XXX.. or ...XXX.

Whoever is unable to make a move, loses. You have to determine who wins if they both play optimally.

You have to answer qq independent queries.

爱丽丝和鲍勃进行一场游戏。初始时,他们有一个仅由字符 . 和 X 组成的字符串 s1,s2,…,sns_1, s_2, \dots, s_n。两人轮流操作,爱丽丝先手。在每一轮中,当前玩家必须选择一个连续子串,该子串中所有字符均为 .,并将其中每个 . 替换为 X。爱丽丝每次必须选择长度恰好为 aa 的子串,而鲍勃每次必须选择长度恰好为 bb 的子串。题目保证 a>ba > b。

例如,若 s=s = ...X..,且 a=3a = 3、b=2b = 2,则爱丽丝操作后,字符串只能变为 XXX.X.(注:原文此处示例有误,按题意应为 XXX.X. 或 XX.XXX 等合法结果;但根据标准题面惯例,此处应理解为将某处连续三个 . 变为 XXX,如原串索引 0–2 的 ... 变为 XXX,得 XXX.X.);而若轮到鲍勃且字符串仍为 ...X..,则他操作后字符串可变为 XX.X..、.XXX.. 或 ...XXX。

无法进行合法操作者判负。你需要判断:当双方均以最优策略进行游戏时,谁将获胜。

你需要回答 qq 个相互独立的查询。

输入格式

The first line contains one integer qq (1≤q≤3⋅1051 \le q \le 3 \cdot 10^5) — the number of queries.

The first line of each query contains two integers aa and bb (1≤b<a≤3⋅1051 \le b \lt a \le 3 \cdot 10^5).

The second line of each query contains the string ss (1≤∣s∣≤3⋅1051 \le |s| \le 3 \cdot 10^5), consisting of only characters . and X.

It is guaranteed that sum of all ∣s∣|s| over all queries not exceed 3⋅1053 \cdot 10^5.

第一行包含一个整数 qq(1≤q≤3⋅1051 \le q \le 3 \cdot 10^5),表示查询次数。

每次查询的第一行包含两个整数 aa 和 bb(1≤b<a≤3⋅1051 \le b \lt a \le 3 \cdot 10^5)。

每次查询的第二行包含字符串 ss(1≤∣s∣≤3⋅1051 \le |s| \le 3 \cdot 10^5),该字符串仅由字符 . 和 X 组成。

保证所有查询中 ∣s∣|s| 的总和不超过 3⋅1053 \cdot 10^5。

输出格式

For each test case print YES if Alice can win and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

对于每个测试用例,如果 Alice 能获胜则输出 YES,否则输出 NO。

您可以以任意大小写形式输出每个字母(例如,字符串 yEs、yes、Yes 和 YES 均会被识别为肯定回答)。

输入输出样例

  • 输入#1

    3
    3 2
    XX......XX...X
    4 2
    X...X.X..X
    5 3
    .......X..X

    输出#1

    YES
    NO
    YES

说明/提示

In the first query Alice can select substring s3…s5s_3 \dots s_5. After that ss turns into XXXXX...XX...X. After that, no matter what move Bob makes, Alice can make the move (this will be her second move), but Bob can't make his second move.

In the second query Alice can not win because she cannot even make one move.

In the third query Alice can choose substring s2…s6s_2 \dots s_6. After that ss turns into .XXXXX.X..X, and Bob can't make a move after that.

在第一次查询中,Alice 可以选择子串 s3…s5s_3 \dots s_5。之后,ss 变为 XXXXX...XX...X。此后,无论 Bob 如何操作,Alice 都可以进行操作(这将是她的第二次操作),但 Bob 无法进行他的第二次操作。

在第二次查询中,Alice 无法获胜,因为她甚至无法进行一次操作。

在第三次查询中,Alice 可以选择子串 s2…s6s_2 \dots s_6。之后,ss 变为 .XXXXX.X..X,且 Bob 此后无法进行任何操作。

输入解题思路,AI测评打分。不知道怎么写?

首页