|
||||||||||
List ReshapeTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 255 Accepted Submission(s): 164 Problem Description ProtectEMmm is learning to use NumPy. She is curious about `reshape` function, and wants to implement it by hand. For simplicity, hers `reshape` function reads a non-nested list (which means, all elements in the list are numbers, not a list), and the size of two dimensions of the output list, and then output a 2-dimension list with the data, the order and the number of elements unchanged, but with the specified shape. A well-formatted Python list can be written as a list of comma-separated values (items) between square brackets `[]`. See the sample input and output for more information. The size of each dimensions describes the shape of the list. A $x \times y$ list consists of $x$ lists, each of which consists of $y$ numbers. For example, a $2 \times 3$ list like `[[1, 2, 3], [4, 5, 6]]`, consists of two lists, each of which consists of three numbers. ProtectEMmm finished implementing it quickly. Could you implement it as fast as she can? Input The first line contains a integer $T$ ($1 \leq T \leq 50$), indicating the number of test cases. In each test case: The first line contains a string $s$, indicating the list in Python. It is guaranteed that $s$ is not an empty list. That is, $s$ is not equal to `[]`. The second line contains two numbers $x, y$, the size of each dimension of the output list. Your output list need to consist of $x$ lists, each of which consists of $y$ numbers. It is guaranteed that the number of elements in $s$ equals to $x \cdot y$, all elements in the list have no leading zeros, and are in the range 0 to 1000, and the sum of the number of elements in all test cases does not exceed $5 \times 10^5$. (请不要使用 scanf 进行读入) Output For each test case, you should print a line of string, the result of your `reshape` operation. Note that you need to print exactly one space between every comma and next item in your output. Sample Input
Sample Output
Source | ||||||||||
|