GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 2 August 2022

[Solution] Mio and Lucky Array Codeforces Solution



G. Mio and Lucky Array
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Mio has an array a consisting of n integers, and an array b consisting of m integers.

Mio can do the following operation to a:

  • Choose an integer i (1in) that has not been chosen before, then add 1 to ai, subtract 2 from ai+1, add 3 to ai+2 an so on. Formally, the operation is to add (1)ji(ji+1) to aj for ijn.

Mio wants to transform a so that it will contain b as a subarray. Could you answer her question, and provide a sequence of operations to do so, if it is possible?

An array b is a subarray of an array a if b can be

Solution Click Below:-  👉CLICK HERE👈

👇👇👇👇👇

 obtained from a by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input

The input consists of multiple test cases. The first line contains a single integer t (1t104) — the number of test cases. The description of test cases follows.

The first line of each test case contains one integer n (2n2105) — the number of elements in a.

The second line of the test case contains n integers a1,a2,,an (105ai105), where ai is the i-th element of a.

The third line of the test case contains one integer m (2mn) — the number of elements in b.

The fourth line of the test case contains m integers b1,b2,,bm (1012bi1012), where bi is the i-th element of b.

It is guaranteed that the sum of n over all test cases does not exceed 2105.

Output

If it is impossible to transform a so that it contains b as a subarray, output 1.

Otherwise, the first line of output should contain an integer k (0kn), the number of operations to be done.

The second line should contain k 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