A12941 | Game With String
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob play a game. Initially they have a string $s_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 $a$ , and Bob must select a substring of length $b$ . It is guaranteed that $a > b$ .
For example, if $s =$ ...X.. and $a = 3$ , $b = 2$ , then after Alice's move string can turn only into XXXX... And if it's Bob's turn and the string $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 $q$ independent queries.
For example, if $s =$ ...X.. and $a = 3$ , $b = 2$ , then after Alice's move string can turn only into XXXX... And if it's Bob's turn and the string $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 $q$ independent queries.
输入格式
The first line contains one integer $q$ ( $1 \le q \le 3 \cdot 10^5$ ) — the number of queries.
The first line of each query contains two integers $a$ and $b$ ( $1 \le b < a \le 3 \cdot 10^5$ ).
The second line of each query contains the string $s$ ( $1 \le |s| \le 3 \cdot 10^5$ ), consisting of only characters . and X.
It is guaranteed that sum of all $|s|$ over all queries not exceed $3 \cdot 10^5$ .
The first line of each query contains two integers $a$ and $b$ ( $1 \le b < a \le 3 \cdot 10^5$ ).
The second line of each query contains the string $s$ ( $1 \le |s| \le 3 \cdot 10^5$ ), consisting of only characters . and X.
It is guaranteed that sum of all $|s|$ over all queries not exceed $3 \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).
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).
输入输出样例
输入 #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 $s_3 \dots s_5$ . After that $s$ 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 $s_2 \dots s_6$ . After that $s$ turns into .XXXXX.X..X, and Bob can't make a move after that.
In the second query Alice can not win because she cannot even make one move.
In the third query Alice can choose substring $s_2 \dots s_6$ . After that $s$ turns into .XXXXX.X..X, and Bob can't make a move after that.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted