Hedge Topiary

시간 제한10초메모리 제한1024 MB

요약
원점이 두 단순 다각형 내부에 엄격히 들어 있을 때, 첫 번째 다각형을 원점 기준으로 확대해 두 번째 다각형 안에 완전히 넣을 수 있는 최대 배율을 구한다.
난이도

어려움10점 중 8점

유형
기하, 이분 탐색
정답자
아직 제출이 없습니다

문제

Our polygon-shaped bush needs a trim. We would like to cut it down to size so that the remaining leaves of the bush form a new shape of our choosing, with its centre sitting on the top of the stem -- represented as the origin (0,0)(0, 0) in both shapes.

Figure H.1: Bushes cut into beautiful shapes, as given in sample inputs 1, 2, & 3.

The original shape of the bush is a little unusual so it is not obvious how large we can make the new shape without leaving some gaps in the design.

Find out the largest scaling factor that you can apply to the new shape to make it fit into the old shape--meaning that there is no point contained by the re-scaled new shape that was not contained by the old shape as well.

입력

  • One line containing the number of coordinates in the new shape, nn (3≤n≤5003 \le n \le 500).
  • nn further lines, the iith of which contains the integer coordinates of the iith vertex in the new shape's polygon, x_iy_ix\_i y\_i (−104≤x,y≤104-10^4 \le x,y \le 10^4).
  • One line containing the number of coordinates in the original shape, mm (3≤m≤5003 \le m \le 500).
  • nn further lines, the iith of which contains the integer coordinates of the iith vertex in the old shape's polygon, u_iv_iu\_i v\_i (−104≤u,v≤104-10^4 \le u,v \le 10^4).

The old and new shapes are not always convex. However, the origin point is strictly inside (not on the bounds of) both shapes and neither of the shapes self-touch, self-intersect, or repeat any vertices.

출력

Output the maximum amount by which we can scale the first given shape around the origin (0,0)(0, 0), such that it is fully contained by the bounds of the second given shape. This amount may be any number greater than 00, meaning the shape may also need to become smaller.

The output must be accurate to an absolute or relative error of at most 10−610^{-6}.

예제3

  1. 예제 1

    입력
    4
    -1 -1
    -1 1
    1 1
    1 -1
    4
    -5 0
    0 -5
    5 0
    0 5
    
    예상 출력
    2.5
    
  2. 예제 2

    입력
    8
    -9 1
    -9 6
    -15 0
    -9 -6
    9 -6
    15 0
    9 6
    9 1
    6
    6 -4
    6 5
    2 1
    -2 1
    -6 5
    -6 -4
    
    예상 출력
    0.4
    
  3. 예제 3

    입력
    4
    2 1
    -2 1
    -1 -1
    2 -1
    5
    -5 3
    -3 -4
    6 -5
    4 1
    6 3
    
    예상 출력
    2