F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Crystal mine

Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 797    Accepted Submission(s): 163


Problem Description
Legends always begin with the sentence ¡°Long long ago......¡±
Long long ago, there is a kingdom. The border of this kingdom is rectangular, and some lakes in it. Old king divides land to N * M areas. So, we can regard this kingdom as a matrix. Every element of matrix is an area. This kingdom is famous for crystal mine, because every land contains an ocean of crystal underground, except lakes.
Now, the old king wants to build a large rectangular mine field in a rectangular range which is decide by him. What¡¯s more, he wants to build a special area in mine field, which can produce crystal manyfold. Notice that mine field can't contain lakes. Unfortunately, the old king is too old to remember something. He always asks his adviser this question with different range.
Adviser is tired of answering those questions day by day. So, you are assigned to solve this problem. You get the kingdom map, and the amount of crystal of every area (as A[][]) has been marked on this map. You should find out the best plan to build this mine field which can produce most crystal. Old king never care the details of plan. The only thing he wants know is the number of crystal the mine field can produce.
 

Input
There are several test cases in the input file.
The first line of input file contains a number T, representing the number of test cases. For each test case:
First line contains four integers separated by a single blank, N (1 <= N <= 150), M (1 <= M <= 150), Q (1<= Q <= 200), S (1 <= S <= 10). The size of matrix is N * M. Q indicates the number of questions of old king. S indicates that, if you set the special area in (i,j), (i,j) will produce S * A[i][j] instead of A[i][j].
The following N lines, each line contains M number, the j-th number of i-th line represent A[i][j] (-1 <= A[i][j] < 100 ). Number -1 indicates that, this area is a lake. Otherwise A[i][j] indicates the amount of crystal in this area.
Following Q line, each line contains four integers p, q, x, y. (1 <= p <= x <= N, 1 <= q <= y <= M) indicating the rectangular range of this question is from (p,q) to (x,y). (p,q) is upper left corner of range, and (x,y) is lower right corner of range.
 

Output
For each test case, first line should contains ¡°Case #: ¡±, ¡±#¡±is case number (starting from 1). Each of the following Q line contains a number indicating the answer of question.
Look at sample output for more details. There is a blank line between two consecutive test cases.
 

Sample Input
1 4 4 3 2 1 -1 0 3 1 1 2 0 2 1 0 -1 1 4 6 1 1 1 1 1 1 1 3 3 1 3 3 4
 

Sample Output
Case 1: 2 9 8
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-08 09:59:01, Gzip enabled