Elephants form two types of formations during migration:
Elephants prefer using merge sort in ascending order. Please help them sort by age, and if the ages are identical, sort by height. If both age and height are the same, maintain the original relative order of the index (stable sort).
This is a partial judge problem. You only need to implement merge_elephants() function, the output function has already been provided for you.
The first line contains a single integer n
- the number of elephants.
2 ≤ n
≤ 105
The following n lines each line contain two integer a
, h
- the age and height of i-th elephant.
1 ≤ a
, h
≤ 109
(Elephants are tall and long-lived animals.)
Output the result of the index in each merge section, the format has already been implemented in the given function.