#P6290. [eJOI 2017] 粒子
[eJOI 2017] 粒子
Description
Two linear particle accelerators are placed facing each other at a distance of . Accelerator fires particles, and accelerator fires particles. When these two types of particles meet, they collide and annihilate. Note that an particle can overtake another particle and nothing happens. The same applies to particles.
Under these conditions, starting from time , accelerators and begin to fire particles and particles, respectively. Each particle moves at a constant speed. The and particles are numbered .
Note: during time , a particle with speed travels a distance .
The launch times of the particles from index to are: , and their speeds are: .
Similarly, the launch times of the particles are: , and their speeds are: .
During the firing process, the following conditions hold:
- Each particle will collide with exactly one particle of the opposite type (the and particles are opposite types to each other).
- When two particles collide, the distance from every other particle to the collision point will be . This condition is guaranteed to hold for the first collisions.
Your task is to write a program to determine the particle pairs in the first collisions.
Input Format
The first line contains three positive integers separated by spaces: .
The next lines each contain two integers: .
The next lines each contain two integers: .
Output Format
Output lines in total.
Each line contains two positive integers , indicating the -th particle and the -th particle.
Line means that the -th particle and the -th particle are the -th pair to collide, i.e. the output order represents the chronological order of collisions.
4 100 2
0 1
2 3
3 2
6 10
0 5
3 10
5 1
7 20
4 2
2 4
Hint
Constraints
For all testdata, it is guaranteed that:
- .
- .
- .
- .
- .
Among them, for of the testdata, .
Notes
The original problem is from: eJOI2017 Problem C Particles
Translation provided by: @_Wallace_
Translated by ChatGPT 5
京公网安备 11011102002149号