Yumi
InterviewTime limit1sMemory limit256 MB
Given Yumi's position and three fixed people on a plane, find the shortest travel distance for Yumi to visit all three people.
- Level
Easy3 of 10
- Topics
- Brute force, Geometry, Implementation
- Solved
- No attempts yet
Problem
Yumi, a cat who loves to be held, and three people are on a two-dimensional coordinate plane. A point on the plane is written as . Yumi wants to be held by all three people. To be held by a person, Yumi must move to the position where that person is. People do not move. Since moving is a hassle, Yumi wants to reach the three people by the shortest route.
For example, if Yumi is at and the three people are at , , and , moving in the order is the shortest route, and its distance is .
Given the positions of Yumi and the three people, find the shortest distance for Yumi to be held by all three.
Input
The first line gives Yumi's position, and the next three lines give the positions of the people, one per line. Each position is given as x-coordinate followed by y-coordinate, separated by a space.
No two people share the same position, and Yumi's position never coincides with a person's position.
Output
Print the shortest distance Yumi travels on the first line. Discard any fractional part and print only the integer part.