Buildings

A building company needs to create a software to analyze a bidimensional plane, that contains the top view of a construction.

Every building that is constructed at the bottom has a height of 1 1 , and the company allows to build one, two, more or no buildings above one building, such that the height of these buildings will increase by 1 1 , and the horizontal and vertical coordinates of these buildings will always fit in the coordinates of the building that is down, so the area will also be smaller.

This file and this file contain the following: in the first line there is a number n n that represents the number of buildings, then there are n n lines that represent the coordinates of every building with the following structure:

x 1 y 1 x 2 y 2 x_1 \quad y_1 \quad x_2 \quad y_2

Where ( x 1 , y 1 ) (x_1,y_1) is the upper left coordinate of the building, and ( x 2 , y 2 ) (x_2,y_2) is the lower right coordinate of the building, and 0 x 1 , y 1 , x 2 , y 2 65535 0 \leq x_1,y_1,x_2,y_2 \leq 65535 .

Your program must compute the total volume for the input given. If the volume for the first file is a a and the volume for the second file is b b , give your answer as ( a + b ) m o d ( 2 16 + 1 ) (a+b) \mod (2^{16}+1) .

For example, consider the following input:

5 60 25 85 45 20 15 45 40 10 5 100 50 30 20 35 35 40 30 42 38 5 \\ 60 \quad 25 \quad 85 \quad 45\\ 20 \quad 15 \quad 45 \quad 40\\ 10 \quad 5 \quad 100 \quad 50\\ 30 \quad 20 \quad 35 \quad 35\\ 40 \quad 30 \quad 42 \quad 38

The plane would be the following (note that the coordinates can be given in any order):

Then, the area for the buildings will be:

[ A ] = ( 100 10 ) ( 50 5 ) = 4050 [ B ] = ( 45 20 ) ( 40 15 ) = 625 [ C ] = ( 85 60 ) ( 45 25 ) = 500 [ D ] = ( 35 30 ) ( 35 20 ) = 75 [ E ] = ( 42 40 ) ( 38 30 ) = 16 [A]=(100-10)(50-5)=4050 \\ [B]=(45-20)(40-15)=625 \\ [C]=(85-60)(45-25)=500 \\ [D]=(35-30)(35-20)=75 \\ [E]=(42-40)(38-30)=16

Now, D D and E E are above B B and B B is above A A , so the height of D D and E E is 3 3 , and the height of B B is 2 2 ; and C C is above A A , so the height of C C is 2 2 and, of course, the height of A A is 1 1 . So, the volume would be:

V = 3 [ D ] + 3 [ E ] + 2 [ B ] + 2 [ C ] + [ A ] V = 3 ( 75 ) + 3 ( 16 ) + 2 ( 625 ) + 2 ( 500 ) + 4050 = 6573 V=3[D]+3[E]+2[B]+2[C]+[A]\\V=3(75)+3(16)+2(625)+2(500)+4050=6573 .


The answer is 42517.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...