P15415 [CCC 2019 S3] Arithmetic Square Arithmetic Square
Description
You are given a $3 \times 3$ grid containing integers.
Among the $9$ cells in the grid, some values are given and the rest are unspecified.
Your task is to determine values for the unspecified cells such that:
* Each row (read from left to right) forms an arithmetic sequence.
* Each column (read from top to bottom) forms an arithmetic sequence.
Recall: an arithmetic sequence of length $3$ is an integer sequence of the form:
$$
a, a + d, a + 2d
$$
where $a$ and $d$ are integers. Note that $d$ can be any integer, including $0$ or a negative integer.
Input Format
The input consists of $3$ lines. Each line contains three space-separated values.
Each value is either an integer (ranging from $-1,000,000$ to $1,000,000$, inclusive) or the symbol `X`.
For $15$ points:
* $4$ points: the input contains at most $3$ `X` values.
* $3$ points: all integer values in the input are between $-10$ and $10$ (inclusive).
* $4$ points: the input contains at least $7$ `X` values.
* $2$ points: all integer values in the input are even.
Output Format
Output $3$ lines. Each line should contain three space-separated integers.
All integers given in the input must remain in the same positions (i.e., the same row and the same column).
All rows and all columns must form arithmetic sequences.
All integers in the output must be between $-1,000,000,000$ and $1,000,000,000$ (inclusive).
If there are multiple solutions, output any one of them. It is guaranteed that at least one solution exists.
Explanation/Hint
### Sample #1 Explanation
Note that the second element in the second row must be $16 + t$.
Because:
$$
20 = 16 + 2t
$$
therefore:
$$
t = 2
$$
so the unspecified element must be:
$$
16 + 2 = 18
$$
A similar reasoning can be used for the second element in the third row.
### Sample #2 Explanation
This is just one of many possible solutions. For example, another solution is:
```
14 16 18
14 16 18
14 16 18
```
Translation source: GPT 5.2.
Translated by ChatGPT 5