#P2526. Pandog's Scenic Walk
Pandog's Scenic Walk
Pandog's Scenic Walk
Grant enjoys walking his dog Pandog along a fixed route that may self-intersect. They start simultaneously at (X1, Y1) and must meet at (Xn, Yn) exactly at the same time. In between, the owner (Grant) moves in a straight line between consecutive meeting points, while Pandog, whose maximum speed is twice that of Grant, can deviate to visit at most one scenic spot during each segment. However, if Pandog detours to a scenic spot S between two consecutive meeting points Pi and Pi+1, the detour must satisfy the following time constraint (using Euclidean distance):
$$ d(P_i, S) + d(S, P_{i+1}) \le 2\;d(P_i, P_{i+1}) $$
In addition, each scenic spot can be visited at most once during the whole journey. Given the coordinates of the n meeting points (in order) and the coordinates of m scenic spots, find the maximum number of scenic spots Pandog can visit while still meeting Grant at every meeting point on time.
inputFormat
The first line contains an integer n (n ≥ 2) denoting the number of meeting points. The following n lines each contain two real numbers representing the coordinates of the meeting points in order: Xi and Yi for 1 ≤ i ≤ n.
The next line contains an integer m representing the number of scenic spots. The following m lines each contain two real numbers representing the coordinates of a scenic spot.
All coordinates are given with at most 6 digits after the decimal point.
outputFormat
Output a single integer, the maximum number of scenic spots Pandog can visit while satisfying the detour condition for each segment.
sample
3
0 0
10 0
20 0
2
5 0
15 0
2