Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are in the construction business. Your company has B employees. The first employee starts from the starting point (A), and all other employees can

image text in transcribedimage text in transcribed You are in the construction business. Your company has B employees. The first employee starts from the starting point (A), and all other employees can start from the starting point (A) or from the location where the house is already built (B). They are guided by a 5050 map, where the starting point (A), the location where the house needs to be built (B), and the location of the obstacle (C) are given as two-dimensional coordinates (x,y). Each player can move 1 in either the horizontal or vertical direction, and in some cases, a player can build multiple houses or no houses at all. Given the map, you want to build a house at every B in the minimum number of moves for all workers. Write a program that outputs the sum of the distances traveled by all workers, satisfying the following conditions. The Conditions Exclude the time to build the house. All workers can only move up, down, left, and right. (They cannot move diagonally) Not all workers must move. Obstacles cannot be passed through. You can't move outside the area shown on the map. (Boundaries are possible) The map is a rectangle with vertices at (0,0),(N,0),(0,N), and (N,N). We assume that there is no case in which B cannot be reached by an obstacle. Input Format On the first line, the number of places to build a house, b, and the number of obstacles, c, are given, separated by spaces. (1b100,1c100,b,c are integers ) On the second line, the coordinates (xA,yA) of the starting point (A) are given, separated by a space. On each line from line 3 to line b+2, the coordinates (xB,yB) of the location (B) where the house should be built are given, separated by a space. The coordinates (xC,yC) of the location (C) where there is an obstacle on each line from line b+3 to line b+c+2 are given, separated by a space. (Each coordinate does not leave the map). Output Format Output the sum of the distances traveled by all workers when all houses in B are built. Write in Python, and use a Greedy algorithm. Timeout per a testcase =12.59s. therefore measuring time is necessary. Include it in the code. Important) I would be very grateful if you could attach a screenshot of the sample output when you put in the sample input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. How can evolutionary theory explain prosocial behaviour?

Answered: 1 week ago

Question

Can workers be trained in ethics? How? Defend your answer.

Answered: 1 week ago