Distance Conditions for Four Points
Time limit2sMemory limit128 MB
Given all pairwise distances among four points as a 4x4 integer matrix, decide if distinct points realizing these distances exist in 3D space.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
A 4 by 4 matrix gives the distances between four points. Determine whether four distinct points can be placed in three-dimensional Euclidean space so that all of the given distances hold at the same time.
Input
The input consists of 4 lines. Each line contains 4 integers. The j-th integer on the i-th line is the distance between point i and point j.
The i-th integer on the i-th line is always 0, and the j-th integer on the i-th line equals the i-th integer on the j-th line. When i and j are different, the value is a positive integer no greater than 10.
Output
Print YES if the given distances can describe four points, and print NO otherwise.
Hint
If every pairwise distance is 1, the four points can be placed at the vertices of a regular tetrahedron.