#IOI20021A. The Troublesome Frog
The Troublesome Frog
Description
Format
Input
Your program is to read from standard input. The first line contains two integers R and C , respectively the number of rows and columns in your rice paddy,. The second line contains the single integer N, the number of flattened rice plants, . Each of the remaining N lines contains two integers, the row number () and the column number () of a flattened rice plant, separated by one blank. Each flattened plant is only listed once.
Output
Your program is to write to standard output. The output contains one line with a single integer, the number of plants flattened along a frog path which did the most damage if there exists at least one frog path, otherwise, 0.
Samples
6 7
14
2 1
6 6
4 2
2 5
2 6
2 7
3 4
6 1
6 2
2 3
6 3
6 4
6 5
6 7
7
6 7
18
1 1
6 2
3 5
1 5
4 7
1 2
1 4
1 6
1 7
2 1
2 3
2 6
4 2
4 4
4 5
5 4
5 5
6 6
4
Limitation
If your program outputs the correct answer for a test case within the time limit, then you get full points for the test case, and otherwise you get 0 points.