Princess, a Strategist
Time limit8sMemory limit512 MB
Given a moving polygon and bullet segments that travel with their own velocities, report every time a bullet first touches the polygon.
- Level
Hard8 of 10
- Topics
- Geometry, Simulation
- Solved
- No attempts yet
Problem
A brave princess from a poor kingdom plans to sneak out of her castle and go on an adventure to recover an ancient treasure. The treasure is guarded by several guardians, so it cannot be reached by ordinary means. The princess has come up with a plan: she will use you, her attendant, as a decoy to draw the guardians' attention while she retrieves the treasure. Following such orders could cost you your life many times over, but you cannot refuse her command. So you scouted ahead and carefully studied how you could move to dodge the guardians' attacks while still drawing their attention. Your job is to write a program that uses these scouting results to calculate when, and how many times, you collide with the bullets fired by the guardians.
For simplicity, consider a two-dimensional plane viewed from high enough above. You wear armor against the guardians' attacks, so you can treat your shape as a polygon. No two edges of this polygon cross or overlap. You may assume the following about your movement.
- You only move in uniform linear motion.
- Acceleration, deceleration, and changes of direction all happen instantly.
- You do not rotate, so your orientation never changes from the initial state.
- Every part of the polygon always has a positive y coordinate.
You may also assume the following about the guardians' bullets.
- The thickness of a bullet is negligible.
- A bullet has a finite length.
- A bullet of length fired from head position with velocity vector has its tail at the following point. (Note: the head's y coordinate is 0 at the moment each bullet is fired.)
- For example, a bullet of length 10 fired from with velocity has its tail at .
- Collisions between bullets fired by enemy characters are all ignored.
A collision between you and a bullet is defined as follows. The collision time of a bullet is the first moment that the polygon forming you and a line segment fired by a guardian share a point. Even if a guardian's bullet hits you, you only take damage and your movement is unaffected. A bullet that hits you disappears at the moment of impact. It is guaranteed that even if you translate the starting position by up to in any direction, the collision times change by at most .
Input
N M B
X1 Y1
...
XN YN
T1 VX1 VY1
...
TM VXM VYM
T'1 X'1 VX'1 VY'1 L1
...
T'B X'B VX'B VY'B LB
Each dataset begins with three non-negative integers (), (), and (). They are the number of vertices of the polygon representing you, the number of movement instructions, and the number of bullets fired by the guardians.
The next lines give the coordinates () of the polygon's vertices at time 0, in order. All values are integers with and .
The next lines give the movement instructions. The -th instruction consists of integers , , , meaning that from time to time your velocity vector is kept at . Here , , and . After the last instruction (that is, at time and later), you stop and stay in place. Bullets can still hit you after you stop, and the output must include those collisions.
The next lines describe the bullets. The -th bullet is given by integers , , , , , meaning a bullet of length is fired at time from with velocity vector . These values satisfy , , , , and .
The input ends with a line containing "0 0 0". This line is not a dataset.
Output
For each dataset, print on the first line the number of times you were hit by bullets fired by the guardians. On each of the following lines, print the collision times in ascending order, with an error of at most 0.001.