AtCoder Regular Contest 194 (Div. 2)
E
Swap 0^X and 1^Y
AtCoder
⌀ 2765
原题
← D→
翻译中…

Problem Statement

翻译中…

You are given two strings $S$ and $T$, each of length $N$ and consisting of 0 and 1, as well as two positive integers $X$ and $Y$. For $i = 1, 2, \ldots, N$, let $S_i$ denote the $i$-th character of $S$.

翻译中…

Determine whether it is possible to make $S$ identical to $T$ by repeatedly performing Operations A and B below any number of times (possibly zero) in any order:

翻译中…
  • (Operation A) Choose an integer $i$ satisfying $1 \leq i \leq N-(X+Y)+1$, $S_{i} = S_{i+1} = \cdots = S_{i+X-1} =$ 0, and $S_{i+X} = S_{i+X+1} = \cdots = S_{i+X+Y-1} =$ 1, then change each of $S_{i}, S_{i+1}, \ldots, S_{i+Y-1}$ to 1 and each of $S_{i+Y}, S_{i+Y+1}, \ldots, S_{i+Y+X-1}$ to 0.
  • (Operation B) Choose an integer $i$ satisfying $1 \leq i \leq N-(X+Y)+1$, $S_{i} = S_{i+1} = \cdots = S_{i+Y-1} =$ 1, and $S_{i+Y} = S_{i+Y+1} = \cdots = S_{i+Y+X-1} =$ 0, then change each of $S_{i}, S_{i+1}, \ldots, S_{i+X-1}$ to 0 and each of $S_{i+X}, S_{i+X+1}, \ldots, S_{i+X+Y-1}$ to 1.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5 \times 10^5$
  • $1 \leq X, Y \leq N$
  • $S$ and $T$ are strings of length $N$ consisting of 0 and 1.
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N X Y
S
T

翻译中…

Output

翻译中…

If it is possible to make $S$ identical to $T$, print Yes; otherwise, print No.

翻译中…

样例

Input #1
9 2 1
000111001
011000011
Output #1
Yes
The following procedure can transform $S$ into $T$: - First, perform Operation A with $i = 2$. Now, $S =$ `010011001`. - Next, perform Operation B with $i = 6$. Now, $S =$ `010010011`. - Finally, perform Operation A with $i = 3$. Now, $S =$ `011000011`. Thus, print `Yes`.
Input #2
1 1 1
0
1
Output #2
No
It is impossible to make $S$ identical to $T$. Thus, print `No`.
题目信息
题号
arc194_e
时间限制
2 s
内存限制
1024 MB

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