Biometrics
Time limit1sMemory limit128 MB
Given two polygons with vertices in matching feature order, decide whether one maps onto the other by translation, rotation, and uniform scaling without reflection.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
Recently the term biometrics has been used to refer to the emerging field of technology devoted to identifying individuals using biological traits, such as retinal or iris scanning, fingerprints, or face recognition.
A simple biometric system turns a human image into a polygon: certain features (eyes, nose, ears, and so on) are treated as vertices and joined by line segments. The polygon's vertices are all distinct, but it may be degenerate in the sense that its segments can cross one another. Because such polygons are usually built from remote images, their scale and rotation are uncertain.
Your task is to decide whether two polygons are similar; that is, whether one can be made to coincide with the other using only translation, rotation, and uniform scaling (magnification). Reflection (mirroring) is not allowed.
Input
The input consists of several test cases. Each test case consists of:
- , the number of features
- coordinate pairs giving the vertices of the first polygon
- coordinate pairs giving the vertices of the second polygon
The vertices of the two polygons correspond to the same set of features in the same order (for example: right ear tip, chin cleft, right eye, nose, left eye, left ear tip, gap between the front teeth). Each polygon has distinct vertices, and each vertex is given as an integer , coordinate pair. The number of features is at least and at most , and every coordinate is an integer between and . A line containing a single follows the last test case.
Output
For each test case, print similar or dissimilar on its own line. The two polygons are similar if, after some combination of translation, rotation, and scaling (but not reflection), every pair of vertices corresponding to the same feature ends up in the same position.