4942. Peak

单点时限: 2.0 sec

内存限制: 1024 MB

Cuber QQ is now studying Cuber Matrix. Cuber Matrix is a $n\times m$ matrix in which the integers $1, 2, \dots, n\times m$ appear in the matrix exactly once.

Cuber QQ finds some interesting numbers in the matrix called Peak Numbers. Peak Numbers are those numbers that are larger than all the other numbers around them (8 directions).

Now, Cuber QQ wants you to construct two Cuber Matrixs such that the number of Peak Numbers in the matrix is minimized or maximized.

输入格式

The first line consists of two integers — $n$ and $m$ ($3 \le n,m \le 1000$), denoting the height and width of the matrix.

输出格式

The first line consists of two integers, denoting the minimum and maximum possible number of the Peak Numbers in a $n\times m$ Cuber Matrix.

In the next $n$ lines, each line consists of $m$ integers per line, denoting one possible Cuber Matrix with the minimum possible numbers of the Peak Numbers.

The next $n$ lines consist of $m$ integers per line, denoting one possible Cuber Matrix with the maximum possible numbers of the Peak Numbers.

样例

Input
4 4
Output
1 4
7 8 9 10
4 5 6 11
1 2 3 16
12 13 14 15
4 1 7 8
2 3 10 12
5 6 11 9
14 13 16 15

提示

In the minimum case, $16$ is the Peak Number.

In the maximum case, $4$, $12$, $14$, and $16$ are the Peak Numbers.

265 人解决,301 人已尝试。

582 份提交通过,共有 995 份提交。

1.6 EMB 奖励。

创建: 2 年,1 月前.

修改: 2 年前.

最后提交: 1 年,9 月前.

来源: N/A

题目标签