Collision of Asteroids
Time limit1sMemory limit16 MB
Given two moving convex hulls in 3D, decide whether they overlap at some past or future time.
- Level
Hard8 of 10
- Topics
- Geometry, Binary search, Implementation
- Solved
- No attempts yet
Problem
Predicting the trajectories and collisions of asteroids is routine work at an observatory. Bob has spent many hours observing two asteroids, so he knows their exact shapes and velocities. After a sleepless night, however, he can no longer tell whether the two asteroids are about to collide or whether they are the debris left over from a past collision.
You are given the shapes of two convex asteroids together with their velocities. Determine whether they have collided in the past or will collide in the future — that is, whether the two bodies share at least one common point at some moment in time.
Each asteroid moves along a straight line at a constant velocity. Gravity is negligible because the asteroids are far from every planet. You may assume that the two asteroids do not share any point at the reference time .
Input
The input consists of two blocks, one per asteroid. Each asteroid is the convex hull of the points given in its block.
A block begins with a line containing an integer (), the number of points. Each of the following lines contains three integers , , and () describing one point. The points are guaranteed not to be coplanar (there exist four of them that do not lie on a common plane). The block ends with a line containing three integers , , and (), the velocity of the asteroid.
Output
Print YES if the asteroids have collided or will collide (they share a common point at some time), and NO otherwise.