AtCoder Regular Contest 223
E
阴阳二位插入
Yin-Yang Two Bits Insertion
AtCoder
⌀ 2572
原题
← DF →

阴阳二位插入AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given integer sequences $A=(A_1,A_2,\dots,A_N)$ and $B=(B_1,B_2,\dots,B_M)$ of length $2$ or more, consisting of $0$s and $1$s. You can perform the following operation on $A$ any number of times:

给定长度至少为 $2$、由 $0$ 和 $1$ 组成的整数序列 $A=(A_1,A_2,\dots,A_N)$ 和 $B=(B_1,B_2,\dots,B_M)$。 你可以对 $A$ 执行任意次以下操作:AI (CI翻译)

  • Choose an integer $i$ satisfying $1 \leq i \leq |A|-1$.
  • Insert $1-A_i$ and $1-A_{i+1}$ in this order between $A_i$ and $A_{i+1}$.
  • 选择满足 $1 \leq i \leq |A|-1$ 的整数 $i$。
  • 按此顺序将 $1-A_i$ 和 $1-A_{i+1}$ 插入到 $A_i$ 与 $A_{i+1}$ 之间。
AI (CI翻译)

Determine whether it is possible to make $A$ equal to $B$.

判断是否可以将 $A$ 变为 $B$。AI (CI翻译)

Solve $T$ test cases per input.

对于每组输入,解决 $T$ 个测试用例。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq T \leq 10^5$
  • $2 \leq N \leq M \leq 2 \times 10^5$
  • $A_i, B_i \in \{0,1\}$
  • The sum of $N+M$ over all test cases is at most $4 \times 10^5$.
  • All input values are integers.
  • $1 \leq T \leq 10^5$
  • $2 \leq N \leq M \leq 2 \times 10^5$
  • $A_i, B_i \in \{0,1\}$
  • 所有测试用例中 $N+M$ 的总和不超过 $4 \times 10^5$。
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

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

输入从标准输入按以下格式给出:AI (CI翻译)

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
AI (CI翻译)

Each test case $\mathrm{case}_t$ is given in the following format:

每组测试用例 $\mathrm{case}_t$ 按以下格式给出:AI (CI翻译)

N M
A_1 A_2 \dots A_N
B_1 B_2 \dots B_M

N M
A_1 A_2 \dots A_N
B_1 B_2 \dots B_M
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output the answers over a total of $T$ lines. The $t$-th line should contain Yes if it is possible to make $A$ equal to $B$ for the $t$-th test case, and No otherwise.

输出共 $T$ 行答案。第 $t$ 行对于第 $t$ 组测试用例,如果可以将 $A$ 变为 $B$,则输出 Yes,否则输出 No。AI (CI翻译)

样例

Input #1
3
3 7
0 1 1
0 1 0 1 1 0 1
2 4
0 1
0 1 0 1
3 4
0 0 0
0 0 0 1
Output #1
Yes
Yes
No
For the first test case, initially $A=(0,1,1)$. First, choosing $i=2$ gives $A=(0,1,0,0,1)$. Next, choosing $i=3$ gives $A=(0,1,0,1,1,0,1)$.
题目信息
题号
arc223_e
时间限制
2 s
内存限制
1024 MB

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