- Time limit: 1.00 s
- Memory limit: 512 MB
You are given two polygons that both have n vertices numbered 1,2,\dots,n. The i-th vertices of polygons 1 and 2 are at positions (x^1_i, y^1_i) and (x^2_i, y^2_i) respectively. There is a line between all pairs of vertices (i-1, i) for i \in \{2,3\dots,n\} and a line between vertices 1 and n. Check if the polygons have the same shape i.e. check if polygon 1 is a moved, scaled and rotated version of the polygon 2. Mirroring is not an allowed operation. Also note that the edges of a polygon might intersect i.e. the polygons might not be simple.
The polygons are considered the same when there is a sequence of move, scale & rotation operations so that after such a sequence the matching vertices of polygons 1 and 2 all lie within 10^{-6} distance of each other.
Note that the problem setter of this task avoids self-inflicted torture like any normal person would. Therefore the task does not have tests that are intentionally designed to test the numerical stability of your solution.
Input
The first line contains a single integer n. The i-th of next n lines contains two integer x^1_i and y^1_i, which shows the vertices of first polygon. The i-th of next n lines contains two integer x^2_i and y^2_i, which shows the vertices of second polygon.
Output
Print "Yes" if the polygons are the same and "No" otherwise.
Constraints
- 3 \leq n \leq 10^5
- -4000 \leq x^1_i, y^1_i, x^2_i, y^2_i \leq 4000
- (x^1_i, y^1_i) \neq (x^1_j, y^1_j) if i \neq j
- (x^2_i, y^2_i) \neq (x^2_j, y^2_j) if i \neq j
Example 1
Input:
4 0 0 0 1 1 1 1 0 0 0 1 1 2 0 1 -1
Output:
Yes
Example 2
Input:
3 0 0 0 2 1 2 0 0 0 2 -1 2
Output:
No
Example 3
Input:
5 -366.1704671086 -357.8889078190 1.8745954997 -4.2267016836 -154.5013572565 -333.2236489526 -251.8988265336 -415.9403461640 -281.4413257844 -81.4918140235 356.7482951051 444.6486788624 350.1820621273 423.2288027266 378.7043578765 450.6364738613 366.5857299537 425.1402800961 359.0377427473 418.7300049941
Output:
Yes