#P1902. 刺杀大使
刺杀大使
Description
A certain organization is planning the assassination of an ambassador. They arrive at the embassy and prepare to carry out the plan. To enter the embassy, they must first get through the defensive maze in front of it.
The maze consists of identical small rooms. Each room is connected by doors to its four neighboring rooms. In row , there are mechanisms located in its rooms, and all of these mechanisms must be switched on to enter the embassy. The rooms in row each has a door that opens to the outside; these are the entrances to the maze. Except for the rooms in rows and , every room has a laser damage device installed by the embassy’s security, which will inflict some damage on anyone entering the room. The damage value of the room at row , column is (all values in rows and are ).
The organization wants to enter the maze and switch on all mechanisms with the minimum damage cost. They may send any number of people through any entrances, but they must reach every room in row . A soldier’s damage is the maximum damage value among all rooms on his path to some mechanism. The whole team’s damage is the maximum among the damages of all soldiers. Given full knowledge of the maze, they need to determine how to arrange the routes so that the team’s damage is minimized.
Input Format
The first line contains two integers , representing the size of the maze.
Then follow lines, each containing numbers. The number at row , column is .
Output Format
Output a single number representing the minimum damage cost.
4 2
0 0
3 5
2 4
0 0
3
Hint
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号