Points
Time limit3sMemory limit128 MB
Given a pattern point set and up to 20 query sets, decide for each whether it is similar to the pattern under rotation, translation, reflection, and scaling.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Hash map, Divide and conquer
- Solved
- No attempts yet
Problem
You are given a set of grid points in the plane (points whose two Cartesian coordinates are both integers); we call this set the pattern. You are also given a family of other sets of grid points in the plane.
For each set, decide whether it is similar to the pattern, i.e. whether it can be turned into a set identical to the pattern by some combination of rotations, translations, reflections and dilations (scalings).
For example, the set is similar to the set , but it is not similar to the set .
Write a program that:
- reads the pattern and the family of investigated sets from standard input,
- determines which of the investigated sets are similar to the pattern,
- writes the result to standard output.
Input
The first line contains a single integer () — the number of points in the pattern. Each of the next lines contains two integers separated by a single space; the -th of them holds the coordinates and () of the -th pattern point. The points of the pattern are pairwise distinct.
The next line contains the number of sets to investigate, (). Then follow the descriptions of the sets. Each description begins with a line containing a single integer () — the number of points in that set. Each of the next lines contains two integers and (), the coordinates of one point. The points belonging to the same set are pairwise distinct.
Output
Print lines, one for each investigated set. On the -th line print TAK (Polish for “yes”) if the -th set is similar to the pattern, or NIE (Polish for “no”) otherwise.
Hint
