#P3418. Similar Point Sets
Similar Point Sets
Similar Point Sets
Given a set of grid points in the plane (i.e. points with integer coordinates) called the pattern set and several other sets of grid points, determine which of the investigated sets are similar to the pattern set. Two sets of points are considered similar if one can be transformed into the other using rotations, translations, reflections, and dilations (scaling). For example, the set {(0,0), (2,0), (2,1)} is similar to the set {(6,1), (6,5), (4,5)}, but it is not similar to the set {(4,0), (6,0), (5,-1)}.
Two similar sets must have the same number of points. In the case when there is only one point in the set, they are trivially similar.
A similarity transformation can be written in the form \[ T(P) = a R P + b, \] where \(a\) is a positive scalar (the dilation factor), \(R\) represents a rotation or reflection (an orthogonal 2\(\times\)2 matrix), and \(b\) is a translation vector.
inputFormat
The input is read from the standard input and has the following format:
- The first line contains an integer \(k\) (\(1 \le k \le 25000\)), representing the number of points in the pattern set.
- The next \(k\) lines each contain two integers separated by a space, representing the \(x\) and \(y\) coordinates of a point in the pattern set. All points in the pattern set are distinct and their coordinates satisfy \(-20000 \le x, y \le 20000\).
- The next line contains an integer \(n\) which is the number of sets to be investigated.
- Then, for each of the \(n\) investigated sets, there is a description starting with a line containing an integer \(l\) (\(1 \le l \le 25000\)) representing the number of points in this set, followed by \(l\) lines each containing two integers (\(x\) and \(y\)) separated by a space. In each set the points are pairwise distinct and satisfy \(-20000 \le x, y \le 20000\).
outputFormat
The output should be written to the standard output. There should be exactly \(n\) lines. The \(i\)th line corresponds to the \(i\)th investigated set: the line should contain the word TAK
if the set is similar to the pattern set, otherwise it should contain the word NIE
(which are Polish for "yes" and "no", respectively).
sample
3
0 0
2 0
2 1
3
3
6 1
6 5
4 5
3
4 0
6 0
5 -1
4
0 0
2 0
2 1
3 3
TAK
NIE
NIE
</p>