#P1074. [NOIP 2009 提高组] 靶形数独
[NOIP 2009 提高组] 靶形数独
Description
Xiaocheng and Xiaohua are both good students who love mathematics. Recently, they have both become fascinated with Sudoku. Competitive as they are, they want to use Sudoku to compete. However, ordinary Sudoku is too easy for them, so they consulted Dr. Z, who brought out his recently invented “Target Sudoku” as their challenge.
The grid of Target Sudoku is the same as ordinary Sudoku: in a large grid there are small subgrids (separated by bold black lines). In this large grid, some numbers are already given. Based on these numbers, use logical reasoning to fill the empty cells with digits to . Each digit cannot repeat within any small subgrid, and cannot repeat within any row or column. Target Sudoku differs from ordinary Sudoku in one respect: each cell has a score, and like a target, the closer it is to the center, the higher the score (see figure).

The specific score distribution is: the innermost single cell (yellow region) is worth points; the ring outside the yellow region (red region) is points per cell; the next ring (blue region) is points per cell; the ring outside the blue region (brown region) is points per cell; and the outermost ring (white region) is points per cell, as shown above. The task is: each person must complete a given Sudoku (each given Sudoku may have multiple valid completions), and strive for the highest total score. The total score is the sum, over all cells, of the product of the cell’s score and the digit filled in that cell when the Sudoku is completed.
As shown below, in this completed Target Sudoku, the total score is . The game rules determine the winner by comparing total scores.

Eager to win, Xiaocheng turns to you, a skilled programmer, to compute the highest possible total score for a given Target Sudoku.
Input Format
There are lines in total. Each line contains integers (each between and inclusive), representing a partially filled Sudoku grid. Unfilled cells are represented by . Each pair of integers is separated by a single space.
Output Format
Output a single line: the maximum total score achievable for the given Target Sudoku. If the Sudoku has no solution, output .
7 0 0 9 0 0 0 0 1
1 0 0 0 0 5 9 0 0
0 0 0 2 0 0 0 8 0
0 0 5 0 2 0 0 0 3
0 0 0 0 0 0 6 4 8
4 1 3 0 0 0 0 0 0
0 0 7 0 0 2 0 9 0
2 0 1 0 6 0 8 0 4
0 8 0 5 0 4 0 1 2
2829
0 0 0 7 0 2 4 5 3
9 0 0 0 0 8 0 0 0
7 4 0 0 0 5 0 1 0
1 9 5 0 8 0 0 0 0
0 7 0 0 0 0 0 2 5
0 3 0 5 7 9 1 0 8
0 0 0 6 0 1 0 0 0
0 6 0 9 0 0 0 0 1
0 0 0 0 0 0 0 0 6
2852
Hint
- Constraints:
- For of the testdata, the number of non-zero entries in the Sudoku is at least .
- For of the testdata, the number of non-zero entries in the Sudoku is at least .
- For of the testdata, the number of non-zero entries in the Sudoku is at least .
NOIP 2009 Senior, Problem 3.
Translated by ChatGPT 5
京公网安备 11011102002149号