F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

List Reshape

Time 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
4 [3, 1, 4, 1, 5, 9, 2, 6] 2 4 [998, 244, 3, 5, 3] 5 1 [1, 1, 2, 3, 5, 8, 13, 21, 34] 1 9 [2, 3, 5, 7, 11, 13, 17, 19, 23] 3 3
 

Sample Output
[[3, 1, 4, 1], [5, 9, 2, 6]] [[998], [244], [3], [5], [3]] [[1, 1, 2, 3, 5, 8, 13, 21, 34]] [[2, 3, 5], [7, 11, 13], [17, 19, 23]]
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 17:29:56, Gzip enabled