#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:
- The incident angle is the angle between the incident ray and the normal vector of the deflection plane.
- Both sides of a deflection device can deflect.
- If the laser is incident parallel to a deflection device, we consider that no deflection occurs.
- If it is not parallel and hits an endpoint, we consider that a deflection occurs.
- When , 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 , indicating that the directional laser emitter is at and points in direction .
The second line contains an integer , the number of laser deflection devices. The next lines each contain six integers , describing one deflection device as the segment from to with deflection coefficient .
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 to in input order). If the laser is deflected more than times, output only the indices of the first 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 and then device in order.

Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, ; the absolute values of all coordinates and of and do not exceed ; and are nonzero; and 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
京公网安备 11011102002149号