CPP-Questions-and-Solutions icon indicating copy to clipboard operation
CPP-Questions-and-Solutions copied to clipboard

PerimetricA1

Open anuragdw710 opened this issue 3 years ago • 3 comments

Enter your question -

After a highly successful haul from the log drive, Connie the contractor is tasked with building a number of houses in the Great White North. For each job, the client has provided a floor plan consisting of NN rectangular rooms, numbered from 1 to NN. From a bird's-eye view, the rooms are arranged on a 2-dimensional plane, with axis-aligned walls. The southern wall of each room has y-coordinate 0. The iith rectangular room has southwest corner (L_i, 0)(L i,0) and northeast corner (L_i + W, H_i)(Li+W,Hi). In this chapter of the problem, all NN rooms have the same width WW, and have strictly increasing LL values (L_1 < L_2 < ... < L_N)(L1<L 2<...<L N ). Since houses often have shared regions (such as a common living/dining area), these rooms may overlap with one another. Unfortunately, log houses are quite susceptible to air leakage. Connie knows that she must install additional insulation to keep the houses warm and energy-efficient during the harsh Canadian winters. In order to determine the amount of insulation material required, Connie will first need to gather some metrics: the perimeters around various combinations of rooms. Specifically, let P_iPibe the perimeter of the union of rooms 1..i1..i. Note that any given point is considered to be within the union if and only if it's within at least one of the rooms' rectangles (including right on an edge), and that the union might not form a single connected polygon. Please help compute the product (P_1 * P_2 * ... * P_N)(P 1∗P 2​∗...∗P N). As this product may be very large, you should compute its value modulo 1,000,000,007.

Enter link to the question(if question belongs to any online platform) -

https://www.facebook.com/codingcompetitions/hacker-cup/2020/round-1/problems/A1

Tags for the question(eg - Array, Basic, Stack, etc.) -

Array,Basic,Searching,Sorting

anuragdw710 avatar Oct 01 '21 07:10 anuragdw710

@SarthakKeshari Please assign me this question.

anuragdw710 avatar Oct 01 '21 07:10 anuragdw710

@anuragdw710, Kindly provide question title

SarthakKeshari avatar Oct 01 '21 08:10 SarthakKeshari

@anuragdw710, Kindly add your solution to "Coding Competition" folder. Deadline - 03/10/2021

SarthakKeshari avatar Oct 01 '21 18:10 SarthakKeshari