User's AC Ratio

93.4% (57/61)

Submission's AC Ratio

36.8% (89/242)

Tags

Description

Magic square is an $n$ by $n$ square grid where each cell of the grid contains distinct integers in the range
$1, 2, \cdots, n^ 2$ , and the sum of each row, column and diagonal is equal.
To create an $n$ by $n$ magic square($n$ is odd), you have to fill in $1, 2, \cdots, n^ 2$ accordingly with the following steps:

  1. Put $1$ in the middle of the first row.
  2. If upper-right cell is empty, move to the upper-right cell, move downward otherwise. And if it is out of the boundary, jump to opposite of the square grid.
  3. Fill in the next integer.
  4. If still haven’t reach $n^ 2$ yet, go to step 2.

Input Format

A positive odd integer $n(n\leq1001)$

Output Format

An $n\times n$ magic square which is generated by the previous steps. Notice that integers in the same row are separated by a single white space, and each row should end with a new line character(‘\n’).

Sample Input 1

3

Sample Output 1

8 1 6
3 5 7
4 9 2

Hints

Problem Source

Subtasks

No. Testdata Range Score
1 0~5 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (KiB) Output Limit (KiB) Subtasks
0 1000 65536 65536 1
1 1000 65536 65536 1
2 1000 65536 65536 1
3 1000 65536 65536 1
4 1000 65536 65536 1
5 1000 65536 65536 1