2009 Bulgarian Olympiad in Informatics
Task 6: Diamonds
The mining company "Dries, fades, blossoms, but gives no fruits" got a concession for development of a diamond deposit - a right-angled cuboid sized L × M × N meters. The geological research estimated the diamond carats in each cubic meter of the deposit. To decide how to develop the deposit, the economists and mining engineers consider many possibilities. They need help calculating the total count of diamond carats in given parts of the deposit. The parts are cuboids with sides parallel to the sides of the deposit. Write down a program diamonds to calculate the carats in the series of parts (not more than 500000) of the deposit.Input
On the first row are three integers L, M, and N (0 < L,M,N ≤ 100) followed by the diamond carats in each cubic meter of the deposit as follows:where Ci,j,k ≤ 2000 carats. On each of the following lines of input are 6 integers x1, y1, z1, x2, y2, z2 - the coordinates of two opposite vertices of a part of the deposit for which the total quantity of carats should be calculated.C1,1,1, C1,1,2, ..., C1,1,L, C1,2,1, C1,2,2, ..., C1,2,L, ... C1,M,1, C1,M,2, ..., C1,M,L, C2,1,1, C2,1,2, ..., C2,1,L, ... C2,M,1, C2,M,2, ..., C2,M,L, ... CN,M,1, CN,M,2, ..., CN,M,L
Output
For each part of the deposit given in the input the program has to a single number - the quantity of the carats in this part.Sample Input
3 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 0 0 0 3 3 2 1 0 1 3 2 2
Sample Output
171 52
All Submissions
Best Solutions
Point Value: 20
Time Limit: 2.00s
Memory Limit: 32M
Added: May 10, 2009
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's quiet in here...