8536: Geometry

内存限制:1024 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:Special Judge 上传者:
提交:4 通过:0

题目描述

NIO loves geometry.


One day he came out with a problem: given two convex polygons in a 2-dimension plane, each with a velocity, what is the moment when they collide? In this problem, it is considered to be a collision that two convex polygons share one point.

输入格式

The first line contains an integer n (3≤n≤50000), denoting the number of vertices of the first convex polygon. Then follows n lines, each line contains two integers xi, yi(−109≤xi, yi≤109), denoting the ith point of the convex polygon. The points are given in counter-clockwise order.


Then follows an integer m (3≤m≤50000), and then m lines, denoting the second polygon. The format and restrictions are the same as above.


The last line contains four integers vx1, vy1, vx2, vy2(−109≤vx1, vy1, vx2, vy2≤109). The velocity of the first polygon is (vx1,vy1)and the velocity of the second polygon is (vx2,vy2).

输出格式

Output a single real number t, indicating how many units of time they collided after the initial state. If the two convex polygons collide at the initial state, print 0. If they will never collide, print −1.


Your answer will be judged to be correct if the relative or absolute error with the jury's answer is less than or equal to 10-6.

输入样例 复制

4
0 0
1 0
1 1
0 1
4
0 2
1 2
1 3
0 3
0 0 -2 -2

输出样例 复制

0.5

分类标签