Path to the parallelepiped
Hard
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
On the surface of a cuboid { (x, y, z) | 0 ≤ x ≤ L, 0 ≤ y ≤ W, 0 ≤ z ≤ H } are two points with coordinates (x_1, y_1, z_1) and (x_2, y_2, 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.
Input
Input file contains (in order) the following 9 integers: L W H x_1 y_1 z_{1 }x_2 y_2 z_2
The numbers are separated by spaces and/or newlines. Each of the numbers L, W, H does not exceed 100.
Output
Derive the output file a single integer - the squared length of the desired path.
Examples
Input #1
Answer #1
Submissions 346
Acceptance rate 5%