The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
James Moriarty planted few bombs all over the city. But sadly there is only one bomb defusing squad, and is at a fixed position (X,Y). Sherlock Holmes was able to find out the positions of all the bombs. So all the bombs are to be disarmed in order to save the city. Since this is a very dangerous task thus no body volunteered.
Sherlock is initially at position (X,Y) and can carry only one bomb at a time. He has to bring all the bombs to the bomb defusing squad. Obviously he wants to do this task as soon as possible.
Given the position of the Squad and position of all the bombs, you need to tell the minimum distance that Sherlock Holmes has to travel to save the city.
First line contains test cases T
Then first line of each test case tells the no. of bombs N ( 3
Next line contain the position of squad X Y ( X,Y
Next N lines denotes the position of bombs- xi yi (xi,yi
For each test case output the minimum distance that Sherlock Holmes will travel.
Note: Bomb Squad is fixed and can not move. Initially Sherlock Holmes is standing with the squad. All the positions are integers. Minimum Distance between two points x1 y1 and x2 y2 is | x1-x2 | + | y1-y2 |.
Input: 1 3 3 4 5 6 2 1 2 3 Output: 20
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