시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 25 | 19 | 18 | 81.818% |
Given a permutation of numbers from 1 to n, find a square matrix conforming to the following rules:
The first line of input is a positive integer n ≤ 500.
The second line of input consists of n space-separated integers: the permutation itself.
The first line of output should be an integer m: the size of the matrix. The next m lines should list m consecutive rows of the matrix. Each of these lines should contain m integers separated by spaces: the values in the corresponding row.
The size m should be minimum possible. If there are several possible answers, print any one of them.
2 1 2
3 1 2 1 2 1 2 1 2 1
Here is where the permutation occurs in the matrix from the example: