This problem is a Mooshak version of a UVA Online Judge Problem.
This year, there have been many problems with population calculations, since in some cities, there
are many emigrants, or the population growth is very high. Every year the ACM (for Association
for Counting Members) conducts a census in each region. The country is divided into \(n^2\) regions,
consisting of an \(n \times n\) grid of regions. Your task is to find the least, and the greatest population in
some set of regions. Since in a single year there is no significant change in the populations, the ACM
modifies the population counts by some number of inhabitants.
In the first line you will find the integer \(n.\). The following \(n\) lines will each contain the \(n\) integers, representing the initial population of city \(c[y,x]\). In the following line is the number \(q\), followed by \(q\) lines with queries, each one being of one of the following two types::
For each query \(q \, y_1 \, x_1 \, y_2 \, x_2\) print in a single line the greatest and least amount of current population in that region, separated by a single space.
Example Input | Example Output |
5 1 2 3 4 5 0 9 2 1 3 0 2 3 4 1 0 1 2 4 5 8 5 3 1 4 4 q 1 1 2 3 c 2 3 10 q 1 1 5 5 q 1 2 2 2 |
9 0 10 0 9 2 |
1 2 3 4 5 0 9 2 1 3 0 2 3 4 1 0 1 2 4 5 8 5 3 1 4
1 2 3 4 5 0 10 2 1 3 0 2 3 4 1 0 1 2 4 5 8 5 3 1 4
1 2 3 4 5 0 9 2 1 3 0 10 3 4 1 0 1 2 4 5 8 5 3 1 4