天天看点

POJ 3608 两凸包最近距离 旋转卡壳

bridge across islands

time limit: 1000ms

memory limit: 65536k

total submissions: 8071

accepted: 2364

special judge

description

thousands of thousands years ago there was a small kingdom located in the middle of the pacific ocean. the territory of the kingdom consists two separated islands. due to the impact of the ocean current, the shapes of both the islands became convex polygons.

the king of the kingdom wanted to establish a bridge to connect the two islands. to minimize the cost, the king asked you, the bishop, to find the minimal distance between the boundaries of the two islands.

POJ 3608 两凸包最近距离 旋转卡壳

input

the input consists of several test cases.

each test case begins with two integers n, m. (3 ≤ n,

m ≤ 10000)

each of the next n lines contains a pair of coordinates, which describes the position of a vertex in one convex polygon.

each of the next m lines contains a pair of coordinates, which describes the position of a vertex in the other convex polygon.

a line with n = m = 0 indicates the end of input.

the coordinates are within the range [-10000, 10000].

output

for each test case output the minimal distance. an error within 0.001 is acceptable.

sample input

sample output

经典题目

代码:

继续阅读