Tiny-Pang plays games
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
说明
Tiny-Pang, recently participated in the development of a new game. Now she has to test it internally, so Tiny-Pang takes the opportunity to mess around and play the game.
This game has a reward link, in a $n \times m$ graph, there are $k$ gold coins, and there may be more than one gold coin in a position.
There are several ways for players to get gold coins:
1. You can get gold coins at an angle of 45 ° clockwise(顺时针) from the horizontal.
2. You can get gold coins at an angle of 90 ° clockwise from the horizontal.
3. You can get gold coins at an angle of 135 ° clockwise from the horizontal.
4. You can get gold coins at an angle of 180 ° clockwise from the horizontal.
Players can choose an arbitrary position to start, choose a specific way.
Because every grid has magic, if the grid is 0, you can only go forward.
If the grid is 1, you can only go back.
Tiny-Pang hopes to get as many gold coins as possible. How many gold coins can she get at most?
**Note:Forward or backward is only related to the character at the start position.**
输入格式
The first line of contains three integers $n, m, k$ $(1 \leq n, m \leq 300, 0 \leq k \leq 300$).
The next $n$ lines, each line contains a string of length $m$.
The next $k$ lines, each line contains two integers $x_i,y_i$,
—— $x_i$ and $y_i$ is the location of the $i$-th gold coin ($1 \leq x_i \leq n, 1 \leq y_i \leq m$).
输出格式
For each test case, print an integer, the answer.
样例
4 5 2
00000
00000
00100
00100
2 3
3 3
1
提示
If this grid is "0", you can choose one of these directions.
If this grid is "1", you can choose one of these directions.