문제
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
Bessie makes observations at the following times:
First,
1 second after the start of the experiment.Then
2 seconds after the first observation.Then
3 seconds after the second observation....
Then
n + 1 seconds after then -th 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.
입력
Each input contains
Each test case consists of three lines. The first line contains
It is guaranteed that the sum of all
출력
For each test case, output the observation number for each particle's disappearance, separated by spaces.
부분문제
| 번호 | 점수 | 조건 |
|---|---|---|
| #1 | 10점 | |
| #2 | 20점 | |
| #3 | 30점 | |
| #4 | 40점 | 추가 제약 조건 없음 |
예제 #1
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
The mootrino (initially moving right) appears at positions
2 \rightarrow 0 \rightarrow 3 \rightarrow -1 \rightarrow 4 \rightarrow -2 \rightarrow 5 \rightarrow -3 .The antimootrino (initially moving left) appears at positions
10 \rightarrow 12 \rightarrow 9 \rightarrow 13 \rightarrow 8 \rightarrow 14 \rightarrow 7 \rightarrow 15 .
Then right at observation
For the second test, the antimootrino starts
Note that we only care about observation numbers, not times or positions.
예제 #2
2
4
1 3 5 8
1 1 1 1
4
1 4 5 8
1 1 1 1
1 1 3 3
7 2 2 7
For the first test:
The two leftmost particles meet at position
2 right at observation1 .The two rightmost particles meet at position
6.5 half a second before observation3 .