#P15415. [CCC 2019 S3] Arithmetic Square 等差方阵

    ID: 17421 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>2019Special JudgeCCC(加拿大)

[CCC 2019 S3] Arithmetic Square 等差方阵

Problem Description

You are given a 3×33 \times 3 grid containing integers.

Among the 99 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 33 is an integer sequence of the form:

a,a+d,a+2da, a + d, a + 2d

where aa and dd are integers. Note that dd can be any integer, including 00 or a negative integer.

Input Format

The input consists of 33 lines. Each line contains three space-separated values.

Each value is either an integer (ranging from −1,000,000-1,000,000 to 1,000,0001,000,000, inclusive) or the symbol X.

For 1515 points:

  • 44 points: the input contains at most 33 X values.
  • 33 points: all integer values in the input are between −10-10 and 1010 (inclusive).
  • 44 points: the input contains at least 77 X values.
  • 22 points: all integer values in the input are even.

Output Format

Output 33 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-1,000,000,000 and 1,000,000,0001,000,000,000 (inclusive).

If there are multiple solutions, output any one of them. It is guaranteed that at least one solution exists.

8 9 10
16 X 20
24 X 30
8 9 10
16 18 20
24 27 30
14 X X
X X 18
X 16 X
14 20 26
18 18 18
22 16 10

Hint

Sample #1 Explanation

Note that the second element in the second row must be 16+t16 + t.

Because:

20=16+2t20 = 16 + 2t

therefore:

t=2t = 2

so the unspecified element must be:

16+2=1816 + 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