#C14455. List to Matrix

    ID: 44106 Type: Default 1000ms 256MiB

List to Matrix

List to Matrix

You are given a list of integers and two positive integers r and c that denote the number of rows and columns respectively. Your task is to arrange the list elements into a matrix of size \(r \times c\) in row-major order.

If the list does not contain enough elements to fill the matrix, fill the remaining positions with 0. If the list contains more elements than needed, ignore the extra elements.

Example:

Input:
2 3
1 2 3 4 5 6

Output: 1 2 3 4 5 6

</p>

This problem tests your ability to manipulate arrays and format the output correctly.

inputFormat

The input is given from standard input (stdin). The first line contains two integers r and c separated by a space, representing the number of rows and columns. The second line contains a sequence of integers separated by spaces which constitutes the list.

outputFormat

Print the resulting matrix to standard output (stdout). Each row should be printed on a new line, with the integers in that row separated by a single space.## sample

2 3
1 2 3 4 5 6
1 2 3

4 5 6

</p>