#TP0000003. Trộn hai dãy tăng (Merge Sequences)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trộn hai dãy tăng (Merge Sequences)
Merge Sequences
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You are given two integer sequences, and . Both sequences are strictly increasing: each element is greater than its predecessor. Furthermore, no element of equals any element of .
Combine all elements and sort them in ascending order to obtain sequence . Because all values are distinct, every original element has a unique position in .
Find the position in of every , followed by the position in of every . Positions are numbered starting from .
Input
- The first line contains two integers and , the lengths of the sequences.
- The second line contains exactly integers in strictly increasing order.
- The third line contains exactly integers in strictly increasing order.
Output
- On the first line, print integers: the positions in of , in this order.
- On the second line, print integers: the positions in of , in this order.
Separate numbers on the same line with spaces. The smallest position is .
Subtasks
- Subtask 1 (20 points): ; ; ; ; for all , .
- Subtask 2 (30 points): ; ; ; ; for all , .
- Subtask 3 (50 points): ; ; ; ; for all , .
Examples
Input
4 3
3 14 15 92
6 53 58
Output
1 3 4 7
2 5 6
Explanation
Combining and sorting the sequences gives . In , the elements , , , and occur at positions , , , and , respectively, so the first line is 1 3 4 7.
Likewise, the elements of , namely , , and , appear at positions , , and , giving the second line 2 5 6.