GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Monday, 27 June 2022

[Solution] Parcels Kick Start Solution | Kickstart 2022


You have been hired recently as the Chief Decision Maker (CDM) at a famous parcel delivery company, congratulations! Customers love speedy deliveries of their parcels and you have decided to decrease the time it takes to deliver parcels around the world to win customers. You have introduced this idea to the authorities and they have allocated you enough budget to build at most one new delivery office.

The world can be divided into an R×C grid of squares. Each square either contains a delivery office or is empty. You may pick a grid square that does not already contain a delivery office and build a new delivery office there.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

The delivery time of a parcel to a square is 0 if that square contains a delivery office. Otherwise, it is defined as the minimum Manhattan distance between that square and any other square containing a delivery office. The overall delivery time is the maximum of delivery times of all the squares. What is the minimum overall delivery time you can obtain by building at most one new delivery office?

Note: The Manhattan distance between two squares (r1,c1) and (r2,c2) is defined as |r1r2|+|c1c2|, where |x| denotes the absolute value of x.

Input

The first line of the input gives the number of test cases, TT test cases follow. The first line of each test case contains the number of rows R and number of columns C of the grid. Each of the next R

 lines contains a string of C characters, where each character is either 0 or 10 denotes the absence of a delivery office and 1 denotes the presence of a delivery office in that square.

Output

For each test case, output one line containing Case #xy, where x is the test case number (starting from 1) and y is the minimum overall delivery time you can obtain after adding at most one additional delivery office.

Limits

Time limit: 15 seconds.
Memory limit: 1 GB.

1T100.
There is at least one delivery office in the initial grid.

Test Set 1

1R10.
1C10.

Test Set 2

1R250.
1C250.

No comments:

Post a Comment