[NOIP simulation test]: marshland (maximum cost feasible flow)

Title Description

In front of a swamp.
Conveniently, we used a $ n \ times n $ trellis diagram to describe it, each grid represents a small area of the swamp. Wherein the bottom right $ (1,1) of the upper left corner of FIG representative grid $, $ (n, n) $ representative grid of FIG. If the number is represented by $ $ X-lines, the Y $ $ denotes the number of columns, the $ X + Y $ odd lattice has a risk of $ 0 $.
In order to protect people's security, you have a $ m $ strange looks big stones, you can choose some stones on certain grid, the stone can be seen as a trellis diagram $ 'L' $-shaped blocks, and accounting three grid, that there are four ways for placement by the rotation, so that only the corners of the lattice risk reduction is $ 0 $.
There trellis diagram $ k $ th position is a "position prohibited", any part of the stone can not be located on the grid, and the risk of these positions must be $ 0 $.
Now you need to know some of the stones are placed after a minimum of risk and how much. (Stone can hold End)


Input Format

The first row of three integers $ n, m, k $.
Next, $ n-n-$ $ $ lines each integers, each square represents a danger to read, $ X + Y $ ensure an even grid and the risk of grid-preventing position to $ 0 $.
Next lines each $ k $ $ $ integer 2 $ X, Y $, coordinates indicating the preventing position, the note may duplicate preventing position.


Output Format

Output line a minimum integer representing the sum of risk.


Sample

Sample input 1:

3 3 1
0 1 0
2 0 1
0 1 0
1 3

Sample output 1:

3

Sample input 2:

3 3 4
0 2 0
0 0 4
0 3 0
1 3
2 1
2 2
3 1

Sample Output 2:

9


 

answer

Guess you like

Origin www.cnblogs.com/wzc521/p/11409282.html