Menu

[Solved] One Day Farmer Peter Got Agricultural Land Friend Plans Divide Land Numbers Field Planting Q37294116

One day, farmer Peter got an agricultural land from his friendand he plans to divide the land into numbers of field for plantingdifferent crops. The land has numbers of non-removable stones thatcan be used to build the partitions of fields. To make it simple,field will be in form of rectangle with its sides either parallelsto x-axis or yaxis. The corners of a field must build on a stone.Fields can share partition and having stone placed inside butcannot be overlapped. For example, the land shown below got 9stones in the middle and four possible fields can be made.

Without overlapping, the final partition of land can be eitherpartition A or B shown below. However, partition A is morepreferable as it gives more area for farming.

Partition B Partition A

After investigated the land closely, Peter found that it is toodifficult for him to work out the best partition and therefore, heasks for your help again. As an engineering student, you decide tosolve it by writing a computer program.

Input:

The first input would be the number of stones in the land, n,followed by n pairs of unsorted stone’s coordinate. The coordinateis inputted as x and y separated by a space, i.e. “x y”, with theorigin on the bottom left corner of the land. Both n, x and y areintegers. You may assume that n<100 and total number of possiblefields in a given land should be less than 100.

Example:

9

2 2

2 5

4 2

4 4

9 4

6 2

6 4

6 5

9 2

A. Write a program to output the numbers of possiblefields (rectangle) that can be built on a given land. The sampleinput and output of 4 lands are shown below.

#1 #2 #3 #4

2 0 0 4 46 2524246 2524 252442452 2 0 9224499911 42244 244 9224496669 1 2 3 4.

B. Write a program to work out the largest farming areasof a given land. The largest farming area is the sum of all thepossible fields that can be built without overlapping with eachother, i.e. the program should partition the land suchthat:

a. Fields do not overlap with each other.

b. The total area of the fields is the largest possibleframing area of the land.

In case more than one partitioning have the largest farmingarea, select the one with larger individual fields. The programshould output the number of non-overlapped fields, followed by thearea of each field in a descending order.

0 0 2 4 2524246 2524 252442452 2 0 9224499911 9224496669 42244 1 3 2 4

We were unable to transcribe this imagePartition B Partition A #1 #2 #3 #4 2 0 0 4 46 2524246 2524 252442452 2 0 9224499911 42244 244 9224496669 1 2 3 4. 0 0 2 4 2524246 2524 252442452 2 0 9224499911 9224496669 42244 1 3 2 4 Show transcribed image text
Partition B Partition A
#1 #2 #3 #4
2 0 0 4 46 2524246 2524 252442452 2 0 9224499911 42244 244 9224496669 1 2 3 4.
0 0 2 4 2524246 2524 252442452 2 0 9224499911 9224496669 42244 1 3 2 4

Expert Answer


Answer to One day, farmer Peter got an agricultural land from his friend and he plans to divide the land into numbers of field for… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *