#P4361. [SHOI2015] 激光发生器

[SHOI2015] 激光发生器

Description

Having once invented the Super Particle Cannon · Modified, the inventor SHTSC has now unveiled his new invention: the Laser Generator — a mysterious device that can produce high-energy lasers.

From a top-down view, the Laser Generator is an infinite plane containing one directional laser emitter and several laser deflection devices. An example is shown in the figure: the thin arrow denotes the directional laser emitter, and the thick segments denote the laser deflection devices.

The laser emitted by the directional emitter can be regarded as a ray. When it encounters a deflection device, it will be deflected. Interestingly, the deflection devices used by SHTSC do not obey the law of reflection like traditional mirrors. For each deflection device, there is a fixed deflection coefficient λλ, and the relation between the exit angle ββ and the incident angle αα is β=λαβ=λα. The device can also amplify the laser’s energy in the process.

Notes:

  1. The incident angle is the angle between the incident ray and the normal vector of the deflection plane.
  2. Both sides of a deflection device can deflect.
  3. If the laser is incident parallel to a deflection device, we consider that no deflection occurs.
  4. If it is not parallel and hits an endpoint, we consider that a deflection occurs.
  5. When β>12πβ>\frac{1}{2}π, it may be deflected to the other side.

Now SHTSC hopes you will simulate the operation of his Laser Generator to help compute which deflection devices the laser is deflected by.

Input Format

The first line contains four integers x,y,dx,dyx, y, dx, dy, indicating that the directional laser emitter is at (x,y)(x, y) and points in direction (dx,dy)(dx, dy).

The second line contains an integer nn, the number of laser deflection devices. The next nn lines each contain six integers x1,y1,x2,y2,a,bx1, y1, x2, y2, a, b, describing one deflection device as the segment from (x1,y1)(x1, y1) to (x2,y2)(x2, y2) with deflection coefficient λ=a/b\lambda=a/b.

Output Format

Output one line with a sequence of integers separated by spaces, indicating the indices of the deflection devices the laser hits in order (devices are numbered from 11 to nn in input order). If the laser is deflected more than 1010 times, output only the indices of the first 1010 devices hit. In particular, if the laser is not deflected by any device, output NONE.

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

Hint

Sample Explanation

As shown in the figure, the laser is deflected by device 11 and then device 22 in order.

Constraints

  • For 10%10\% of the testdata, n=1n=1.
  • For 40%40\% of the testdata, a=b=1a=b=1.
  • For 100%100\% of the testdata, n100n \le 100; the absolute values of all coordinates and of aa and bb do not exceed 10001000; aa and bb are nonzero; dxdx and dydy are not both zero. It is guaranteed that no two deflection devices intersect, and the starting point of the laser emitter is not on any deflection device.

Translated by ChatGPT 5