2038: [USACO 2024 February Contest Gold] Problem 3. Quantum Moochanics
题目描述
In her free time, Bessie likes to dabble in experimental physics. She has recently discovered a pair of new subatomic particles, named mootrinos and antimootrinos. Like standard matter-antimatter pairs, mootrinos and antimootrinos annihilate each other and disappear when they meet. But what makes these particles unique is that they switch their direction of motion (while maintaining the same speed) whenever Bessie looks at them.
For her latest experiment, Bessie has placed an even number () of these particles in a line. The line starts with a mootrino on the left and then alternates between the two types of particles, with the -th particle located at position (). Mootrinos initially move right while antimootrinos initially move left, and the -th particle moves with a constant speed of units per second ().
Bessie makes observations at the following times:
- First, second after the start of the experiment.
- Then seconds after the first observation.
- Then seconds after the second observation.
- ...
- Then seconds after the -th observation.
This experiment may take an extremely long time to complete, so Bessie would like to first simulate its results. Given the experiment setup, help Bessie determine when (i.e., the observation number) she will observe each particle disappear! It may be shown that all particles will eventually disappear.
输入
Each test case consists of three lines. The first line contains , the second line contains , and the third line contains .
It is guaranteed that the sum of all does not exceed .
输出
样例输入
4
2
1 11
1 1
2
1 12
1 1
2
1 11
4 6
2
1 11
4 5
样例输出
9 9
11 11
1 1
3 3
提示
For the first test, Bessie observes the following during the first observations:
- The mootrino (initially moving right) appears at positions .
- The antimootrino (initially moving left) appears at positions .
For the second test, the antimootrino starts additional unit to the right, so the two particles meet at position half a second before observation .
Note that we only care about observation numbers, not times or positions.
SAMPLE INPUT:
2
4
1 3 5 8
1 1 1 1
4
1 4 5 8
1 1 1 1
SAMPLE OUTPUT:
1 1 3 3
7 2 2 7
For the first test:
- The two leftmost particles meet at position right at observation .
- The two rightmost particles meet at position half a second before observation .
SCORING:
- Input 3 satisfies .
- Input 4 satisfies and for all cows.
- Inputs 5-7 satisfy .
- Inputs 8-12 satisfy no additional constraints.