RoAlgo Weekly Contest #1 | simetrie

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 64MB Input: Output:

Task

Write a C/C++ program that reads a natural number nn and a sequence of nn natural numbers in range [0,104][0, 10^4]. It constructs in memory a two-dimensional array with nn rows and nn columns, indexed starting from 11, such that by traversing any column with an odd number, from top to bottom, or any column with an even number, from bottom to top, the given sequence is obtained, as shown in the example.

The program should display the resulting array on the screen, with each row of the array on a new line, and the elements of the same row separated by a space.

Example: If n=4n=4, and the given sequence is 7 2 5 37 \ 2 \ 5 \ 3, the resulting array is as follows.

7 3 7 3
2 5 2 5
5 2 5 2
3 7 3 7

Input data

The first line contains two integers, aa and bb.

Output data

The required two-dimensional array from the statement will be printed.

Constraints and clarifications

  • 1n1001 \leq n \leq 100;
  • The values are in the range [0,104][0, 10^4].

Example

stdin

4
7 2 5 3

stdout

7 3 7 3
2 5 2 5
5 2 5 2
3 7 3 7

Log in or sign up to be able to send submissions!