#P3888. [GDOI2014] 拯救莫莉斯
[GDOI2014] 拯救莫莉斯
Description
Morris Qiao is a formidable figure in the Sanctuary. With his outstanding economic acumen, he firmly controls the oil market there.
The map of the Sanctuary can be seen as an grid. Each integer coordinate represents a city (). The definition of adjacency between two cities is: for cities and , they are adjacent if .
Because the total volume of oil trade in the Sanctuary is large, Morris realizes that he cannot dispatch every oil order from the same depot. To improve efficiency, Morris Qiao decides to build depots in some cities, so that every city satisfies one of the following:
- City has a depot itself.
- There exists a city with a depot, and city is adjacent to city .
As on Earth, land prices may differ between cities in the Sanctuary, so Morris wants to minimize the total cost of achieving the goal. If multiple plans have the same minimum total cost, to facilitate management, Morris will choose the one with fewer depots.
Input Format
The first line contains two positive integers (with and ), representing the size of the grid.
Then follows an -by- matrix , where denotes the cost to build a depot in city .
Output Format
Output two numbers: the number of depots and the minimum total cost.
3 3
6 5 4
1 2 3
7 8 9
3 6
Hint
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号