#P1025. Problem 3. Quantum Moochanics

Problem 3. Quantum Moochanics

当前没有测试数据。

一、Problem Name

Quantum Moochanics

二、Problem Description

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 NN (2N21052\leq N\leq2\cdot10^5) 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 iith particle located at position pip_i (0p1<<pN10180\leq p_1<\cdots<p_N\leq10^{18}). Mootrinos initially move right while antimootrinos initially move left, and the iith particle moves with a constant speed of sis_i units per second (1si1091\leq s_i\leq10^9).

Bessie makes observations at the following times:

  1. First, 1 second after the start of the experiment.
  2. Then 2 seconds after the first observation.
  3. Then 3 seconds after the second observation.
  4. ……
  5. Then n+1n + 1 seconds after the nnth observation.

During each observation, Bessie notes down which particles have disappeared.

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.

三、Input Format (input arrives from the terminal / stdin)

  1. Each input contains TT (1T101\leq T\leq10) independent test cases.
  2. Each test case consists of three lines. The first line contains NN, the second line contains p1,,pNp_1,\cdots,p_N, and the third line contains s1,,sNs_1,\cdots,s_N.
  3. It is guaranteed that the sum of all NN does not exceed 21052\cdot10^5.

四、Output Format (print output to the终端 / stdout)

For each test case, output the observation number for each particle's disappearance, separated by spaces.

五、Sample Input and Output

Sample Input 1

4
2
1 11
1 1
2
1 12
1 1
2
1 11
4 6
2
1 11
4 5

Sample Output 1

9 9
11 11
1 1
3 3

Explanation: For the first test, Bessie observes the following during the first 8 observations: The mootrino (initially moving right) appears at positions $2\rightarrow0\rightarrow3\rightarrow - 1\rightarrow4\rightarrow - 2\rightarrow5\rightarrow - 3$. The antimootrino (initially moving left) appears at positions $10\rightarrow12\rightarrow9\rightarrow13\rightarrow8\rightarrow14\rightarrow7\rightarrow15$. Then right at observation 9, the two particles meet at position 6 and annihilate each other. For the second test, the antimootrino starts 1 additional unit to the right, so the two particles meet at position 6.5 half a second before observation 11. Note that we only care about observation numbers, not times or positions.

Sample Input 2

2
4
1 3 5 8
1 1 1 1
4
1 4 5 8
1 1 1 1

Sample Output 2

1 1 3 3
7 2 2 7

Explanation: For the first test: The two leftmost particles meet at position 2 right at observation 1. The two rightmost particles meet at position 6.5 half a second before observation 3.

六、Scoring Rules

  1. Input 3 satisfies N=2N = 2.
  2. Input 4 satisfies N2000N\leq2000 and pi104p_i\leq10^4 for all cows.
  3. Inputs 5 - 7 satisfy N2000N\leq2000.
  4. Inputs 8 - 12 satisfy no additional constraints.

Problem credits: Aryansh Shrivastava, Benjamin Qi.