Where are they?
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Once, Zenyk and Marichka wanted to go on a Plast hiking route. A Plast route is a set of \(n\) checkpoints, between which you need to walk along straight lines in the order of increasing point numbers. The route is closed, and from point \(n\) you need to move to point 1.
Zenyk found a map of this route on the internet with all the checkpoints numbered on it. Upon arrival, Zenyk and Marichka realized that it would not be easy for them. After walking for a few hours, Marichka and Zenyk got lost. But they were lucky — they reached one of the checkpoints near which a map of the route was drawn.
This map depicted the same route as Zenyk’s map. The points were labeled in the same order. But there were a few differences. The map at the checkpoint was rotated by some angle, and the numbering of the checkpoints on it started from the point Zenyk and Marichka had just arrived at.
Help Zenyk determine what number on his map corresponds to the checkpoint they have just arrived at.
Input
The first line contains a single integer \(n\) — the number of checkpoints in the route.
The second line contains \(2 \cdot n\) integers. \(x_1, y_1, x_2, y_2\) and so on ... — the coordinates of the checkpoints on Zenyk’s map.
The third line in the same format gives the numbers \(mx_i, my_i\) — the coordinates of the points on the map from the checkpoint.
It is guaranteed that the routes on Zenyk’s map and on the map from the checkpoint match. Also, the checkpoints on the maps are numbered in the same direction.
Output
In a single line, output a single integer — the number by which the checkpoint where Zenyk and Marichka are currently located is marked on Zenyk’s map.
If there are several such points, output the smallest one.
Constraints
\(-10^5 \le x_i, y_i, mx_i, my_i \le 10^5\).
40% of tests:
\(3 \le n \le 1000\),
the sides of the route are parallel to the coordinate axes,
the map at the checkpoint is rotated by an angle that is a multiple of \(90^{\circ}\).
60% of tests:
\(3 \le n \le 10^5\),
the sides of the route are arbitrary,
the map at the checkpoint is rotated by an arbitrary angle.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 6 2 -6 -4 -6 -4 -2 4 -2 4 4 2 4 3 -4 3 4 -3 4 -3 2 7 2 7 -4 | 3 |
| Input (stdin) | Output (stdout) |
|---|---|
| 6 1 4 5 7 5 2 -3 -4 -3 -9 1 -6 5 1 -5 1 -8 -3 -3 -3 3 5 8 5 | 3 |
Notes
In the first test, the map at the checkpoint was rotated by \(270^{\circ}\) clockwise relative to Zenyk’s map. The point numbered 1 on the map from the checkpoint corresponds to the point numbered 3 on Zenyk’s map.
In the second test, the map at the checkpoint was rotated by \(36.87^{\circ}\) clockwise. The point numbered 1 on the map from the checkpoint corresponds to the point numbered 3 on Zenyk’s map.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|