P6518 [CEOI 2010] arithmetic (day1)

Description

You are given an $R \times C$ matrix. Some cells are already filled with numbers, and some cells are empty, represented by `.`. You need to find a way to fill in the matrix so that the sequence formed by the numbers in each row (in order) and each column (in order) is an arithmetic progression.

Input Format

The first line contains two integers $R, C$, representing the number of rows and columns of the matrix. The next $R$ lines each contain $C$ numbers or characters: `.` or a number.

Output Format

Output $R$ lines in total, each containing $C$ integers or fractions, representing the completed matrix. The fraction format is `N/D`, where $N$ and $D$ are coprime integers. If $D = 1$, omit `/D`. If no solution exists, output `No solution.` All numbers in the output do not exceed $20$ digits. **Note: The testdata guarantees that all input numbers are integers, but the output may contain real numbers, which must be represented as fractions. There may be multiple valid solutions; output any one. This problem uses SPJ.**

Explanation/Hint

#### Sample Explanation #### Sample 1 Explanation We can first fill in $6$ at row 2, column 5, then fill in the first row and the second row, and finally fill in the first column and the fourth column. #### Sample 4 Hint The output is one of multiple possible solutions. #### Constraints **This problem uses bundled testdata.** The testdata is divided into the following $10$ subtasks, each worth $10$ points. |Subtask ID|Limit| |:-:|:-:| |$1$|All numbers are already filled in.| |$2$|$R = 1$ or $C = 1$| |$3$|$R = C = 2$| |$4$|The solution is guaranteed to be unique, and the method used in Sample 1 can be applied.| |$5$|The solution is guaranteed to be unique, and the answer contains only integers.| |$6$|The solution is guaranteed to be unique.| |$7$|Each test case can only have either a unique solution that contains only integers, or no solution.| |$8$|Each test case has only a unique solution, or no solution.| |$9$|No special restrictions.| |$10$|No special restrictions.| - In subtasks $1 \sim 9$, it is guaranteed that $1 \le R, C \le 6$. - For all test points, it is guaranteed that $1 \leq R, C \leq 50$, and all given numbers in the matrix are between $-100 \sim 100$. #### Notes **This problem is translated from [CEOI 2010](http://ceoi2010.ics.upjs.sk/Contest/Tasks) day 1 *[T2 arithmetic](https://people.ksp.sk/~misof/ceoi2010/ari-eng.pdf)***. The translation copyright belongs to the problem provider @[ShineEternal](https://www.luogu.com.cn/user/45475). Reproduction without permission is prohibited. The SPJ is provided by @[一扶苏一](https://www.luogu.com.cn/user/65363). Special thanks. Translated by ChatGPT 5