#5754. [NWRRC 2023] Loops
[NWRRC 2023] Loops
[NWRRC 2023] Loops
题目描述
Consider four integers $A$, $B$, $C$, and $D$, such that $A < B < C
There are three possible loop shapes we can get:

Now consider an matrix filled with distinct integers from to , inclusive. Each square in this matrix can be seen as a square with integers in its corners. Let's build a loop for each of these squares like we did before:

Your task is to perform the inverse operation. You are given the shape types for all loops, and you need to build an matrix filled with distinct integers from to , inclusive, that produces these shapes.
输入格式
The first line contains two integers $n$ and $m$ ($2\le n, m\le 500$).Each of the next lines contains a string of characters without spaces. Each character is a digit from to , denoting the type of the shape of the corresponding loop.
输出格式
Print an $n\times m$ matrix filled with distinct integers from $1$ to $nm$, inclusive, that produces the shapes of the loops in the input.It can be shown that such a matrix always exists. If there are multiple answers, print any of them.
3 4
113
231
9 11 7 12
4 6 1 8
2 10 5 3