AtCoder Grand Contest 060
B
Unique XOR Path
AtCoder
⌀ 1996
原题
← AC →
翻译中…

Problem Statement

翻译中…

We have a grid with $N$ rows and $M$ columns. You want to write an integer between $0$ and $2^K-1$ in each square in the grid to satisfy the following condition.

翻译中…
  • Consider a path that starts at the top-left square, repeatedly moves right or down to an adjacent square, and ends at the bottom-right square. Such a path is said to be good if and only if the total $\mathrm{XOR}$ of the integers written on the squares visited (including the starting and ending points) is $0$.
  • There is exactly one good path, which is the path represented by a string $S$. The path represented by the string $S$ is a path that, for each $i$ ($1 \leq i \leq N+M-2$), the $i$-th move is right if the $i$-th character of $S$ is R and down if that character is D.
翻译中…

Determine whether there is a way to write integers that satisfies the condition.

翻译中…

For each input file, solve $T$ test cases.

翻译中…

What is bitwise $\mathrm{XOR}$? The bitwise $\mathrm{XOR}$ of non-negative integers $A$ and $B$, $A \oplus B$, is defined as follows. When $A \oplus B$ is written in binary, the $k$-th lowest bit ($k \geq 0$) is $1$ if exactly one of the $k$-th lowest bits of $A$ and $B$ is $1$, and $0$ otherwise. For instance, $3 \oplus 5 = 6$ (in binary: $011 \oplus 101 = 110$). Generally, the bitwise $\mathrm{XOR}$ of $k$ non-negative integers $p_1, p_2, p_3, \dots, p_k$ is defined as $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$, which can be proved to be independent of the order of $p_1, p_2, p_3, \dots, p_k$.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 100$
  • $2 \leq N,M \leq 30$
  • $1 \leq K \leq 30$
  • $S$ is a string containing exactly $N-1$ Ds and $M-1$ Rs.
  • All numbers in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
case_1
case_2
\vdots
case_T

翻译中…

Each case is in the following format:

翻译中…

N M K
S

翻译中…

Output

翻译中…

For each case, print Yes if there is a way to write integers that satisfies the condition, and No otherwise. Each character in the output may be either uppercase or lowercase.

翻译中…

样例

Input #1
4
2 2 1
RD
4 3 1
RDDDR
15 20 18
DDRRRRRRRDDDDRRDDRDRRRRDDRDRDDRRR
20 15 7
DRRDDDDDRDDDRRDDRRRDRRRDDDDDRRRDD
Output #1
Yes
No
Yes
No
As an example, for the first case, you can make the grid as follows.
题目信息
题号
agc060_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。