Under construction

Still being built. Things may change

Princess, a Strategist

Time limit8sMemory limit512 MB

Summary
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 ll fired from head position (x,0)(x, 0) with velocity vector (vx,vy)(v_x, v_y) has its tail at the following point. (Note: the head's y coordinate is 0 at the moment each bullet is fired.) (x−l⋅vxvx2+vy2,0−l⋅vyvx2+vy2)\left( x - \frac{l \cdot v_x}{\sqrt{v_x^2 + v_y^2}}, 0 - \frac{l \cdot v_y}{\sqrt{v_x^2 + v_y^2}} \right)
    • For example, a bullet of length 10 fired from (4,0)(4, 0) with velocity (3,4)(3, 4) has its tail at (−2,−8)(-2, -8).
  • 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 10−610^{-6} in any direction, the collision times change by at most 10−510^{-5}.

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 NN (3≤N≤203 \le N \le 20), MM (0≤M≤1000 \le M \le 100), and BB (0≤B≤1000 \le B \le 100). 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 NN lines give the coordinates (Xi,Yi)(X_i, Y_i) (1≤i≤N1 \le i \le N) of the polygon's vertices at time 0, in order. All values are integers with −10000≤Xi≤10000-10000 \le X_i \le 10000 and 0<Yi≤100000 < Y_i \le 10000.

The next MM lines give the movement instructions. The ii-th instruction consists of integers TiT_i, VXiVX_i, VYiVY_i, meaning that from time Ti−1T_{i-1} to time TiT_i your velocity vector is kept at (VXi,VYi)(VX_i, VY_i). Here 0=T0<T1<⋯<TM≤100000 = T_0 < T_1 < \dots < T_M \le 10000, −100≤VXi≤100-100 \le VX_i \le 100, and −100≤VYi≤100-100 \le VY_i \le 100. After the last instruction (that is, at time TMT_M 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 BB lines describe the bullets. The ii-th bullet is given by integers Ti′T'_i, Xi′X'_i, VXi′VX'_i, VYi′VY'_i, LiL_i, meaning a bullet of length LiL_i is fired at time Ti′T'_i from (Xi′,0)(X'_i, 0) with velocity vector (VXi′,VYi′)(VX'_i, VY'_i). These values satisfy 0≤T1′≤T2′≤⋯≤TB′≤100000 \le T'_1 \le T'_2 \le \dots \le T'_B \le 10000, −10000≤Xi′≤10000-10000 \le X'_i \le 10000, −100≤VXi′≤100-100 \le VX'_i \le 100, 0<VYi′≤1000 < VY'_i \le 100, and 0<Li≤1000 < L_i \le 100.

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 nn of times you were hit by bullets fired by the guardians. On each of the following nn lines, print the collision times in ascending order, with an error of at most 0.001.

Examples1

  1. Example 1

    Input
    4 1 1
    1 1
    1 2
    -1 2
    -1 1
    2 1 0
    0 1 0 1 2
    0 0 0
    
    Expected output
    1
    1.000