Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 1 Day Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 8.00

Gas leakages at chemical plants

Gas leakages at chemical plants might prove to be fatal and put the lives of the workers at risk.

 

The aim is to detect the leakage of a gas and prevent its explosion. Our friend Ramesh has successfully obtained the tender to set up a chemical plant to supply fertilizers to the nearby villages. A magnanimous person by heart, he has always put the welfare of the workers above all. So, safety measures have to be taken.

 

For that worst case possibility is considered here.

 

The rooms of the plant can be modelled as axb matrix. The gas used in his plant has a queer property.

 

In times of its leakage, it expands according to the following rules:

 

If at time t, gas leaks from room (x ,y), then at time t+1 it can breaks the doors of atmost two more rooms out of (x+1,y), (x-1,y), (x,y+1), (x,y-1) and expands.

 

For example if at t = 0 sec if the gas occupies (2, 3), then at time t = 1 sec, the rooms filled with gas can be any of the given 6 possibilities:

1. Rooms at (2,3), (3,3) and (2,4). 2. Rooms at (2,3), (3,3) and (1,3). 3. Rooms at (2,3), (3,3) and (2,2). 4. Rooms at (2,3), (2,4) and (1,3). 5. Rooms at (2,3), (2,4) and (2,2). 6. Rooms at (2,3), (2,2) and (1,3). Note: At t= 2 sec, it can expand from all the rooms that are full of gas t= 1.

The gas explodes after gas fills all the rooms and there is no room for it to expand.
Find the minimum time gas takes for the whole plant to explode and help Ramesh ensure the safety of his workers.

 

Input

 

T - The number of test cases.

 

a b - number of row and columns in the room matrix.

 

x y- coordinate of the room where the gas leaked first.

 

Output

 

The minimum time in seconds the plant take to explode.

 

Constraints

1

Example

Input: 2 9 9 2 6 1 1 1 1 Output: 12 0

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)