AT_arc223_e.Yin-Yang Two Bits Insertion
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given integer sequences A=(A1,A2,…,AN) and B=(B1,B2,…,BM) of length 2 or more, consisting of 0s and 1s.
You can perform the following operation on A any number of times:
- Choose an integer i satisfying 1≤i≤∣A∣−1.
- Insert 1−Ai and 1−Ai+1 in this order between Ai and Ai+1.
Determine whether it is possible to make A equal to B.
Solve T test cases per input.
给你两个长度至少为 2 的由 0 和 1 构成的整数序列 A=(A1,A2,…,AN) 和 B=(B1,B2,…,BM)。
你可以在 A 上执行以下操作任意多次:
- 选择一个满足 1≤i≤∣A∣−1 的整数 i;
- 在 Ai 和 Ai+1 之间按顺序插入 1−Ai 和 1−Ai+1。
判断是否可能通过若干次操作使 A 变为 B。
每组输入包含 T 个测试用例,需全部求解。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case caset is given in the following format:
N M
A1 A2 … AN
B1 B2 … BM
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例 caset 按以下格式给出:
N M
A1 A2 … AN
B1 B2 … BM
输出格式
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 行应包含 Yes(如果第 t 个测试用例中可以使 A 等于 B),否则包含 No。
输入输出样例
输入#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
输出#1
Yes Yes No
说明/提示
Sample 1 Explanation:
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).
Constraints
- 1≤T≤105
- 2≤N≤M≤2×105
- Ai,Bi∈0,1
- The sum of N+M over all test cases is at most 4×105.
- All input values are integers.
样例 1 解释:
对于第一个测试用例,初始时 A=(0,1,1)。
首先,选择 i=2,得到 A=(0,1,0,0,1)。
接着,选择 i=3,得到 A=(0,1,0,1,1,0,1)。
约束条件
- 1≤T≤105
- 2≤N≤M≤2×105
- Ai,Bi∈{0,1}
- 所有测试用例中 N+M 的总和不超过 4×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?