问题 A: A boring problem
题目描述
Farmer John, a very boring man, gives Q boring queries to Bessie. The i-th query consists of four integers , , and and asks her the following: when the rectangular region of the grid bounded by (and including) the -th row, -th row, -th column and -th column is cut out, how many connected components consisting of blue squares there are in the region?
输入
The input is given from Standard Input in the following format:
$N \qquad M \qquad Q$
$S_{1,1}..S_{1,M}$
....
$S_{N,1}..S_{N,M}$
$x_{1,1} \quad y_{1,1} \quad x_{1,2} \quad y_{1,2} $
...
$x_{Q,1} \quad y_{Q,1} \quad x_{Q,2} \quad y_{Q,2}$
输出
样例输入
3 4 4
1101
0110
1101
1 1 3 4
1 1 3 1
2 2 3 4
1 2 2 4
样例输出
3
2
2
2
提示
In the first query, the whole grid is specified. There are three components consisting of blue squares, and thus should be printed.
In the second query, the region within the red frame is specified. There are two components consisting of blue squares, and thus should be printed. Note that squares that belong to the same component in the original grid may belong to different components.
Constraints
- is either or .
- satisfies the condition explained in the statement.