eolymp
bolt
Try our new interface for solving problems
Problems

Path to the parallelepiped

Path to the parallelepiped

On the surface of a cuboid \{ (\textbf{x}, \textbf{y}, \textbf{z}) | \textbf{0} ≤ \textbf{x}\textit{ }≤ \textbf{L}, \textbf{0} ≤ \textbf{y}\textit{ }≤ \textbf{W}, \textbf{0} ≤ \textbf{z}\textit{ }≤ \textbf{H} \} are two points with coordinates (\textbf{x_1}, \textbf{y_1}, \textbf{z_1}) and (\textbf{x_2}, \textbf{y_2}, \textbf{z_2}). There are many ways of passing on the surface of the boxes, and connecting the given points. Required to find the square of the length of the shortest such paths. \InputFile Input file contains (in order) the following \textbf{9} integers: \textbf{L W H x_1 y_1 z_\{1 \}x_2 y_2 z_2} The numbers are separated by spaces and\textbf{/}or newlines. Each of the numbers \textbf{L}, \textbf{W}, \textbf{H} does not exceed \textbf{100}. \OutputFile Derive the output file a single integer - the squared length of the desired path.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 4 4
1 2 4
3 2 1
Output example #1
25