[Solution] Mio and Lucky Array Codeforces Solution
Mio has an array consisting of integers, and an array consisting of integers.
Mio can do the following operation to :
- Choose an integer () that has not been chosen before, then add to , subtract from , add to an so on. Formally, the operation is to add to for .
Mio wants to transform so that it will contain as a subarray. Could you answer her question, and provide a sequence of operations to do so, if it is possible?
An array is a subarray of an array if can be
obtained from by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains one integer () — the number of elements in .
The second line of the test case contains integers (), where is the -th element of .
The third line of the test case contains one integer () — the number of elements in .
The fourth line of the test case contains integers (), where is the -th element of .
It is guaranteed that the sum of over all test cases does not exceed .
If it is impossible to transform so that it contains as a subarray, output .
Otherwise, the first line of output should contain an integer (), the number of operations to be done.
The second line should contain distinct integers, representing the operations done in order.
If there are multiple solutions, you can output any.
Notice that you do not need to minimize the number of operations.
No comments:
Post a Comment