#C7251. Reorder Packets
Reorder Packets
Reorder Packets
You are given two lists: one containing packet data and the other containing corresponding indices. Your task is to reorder the packets so that for each pair, the packet appears at the position specified by its corresponding index.
More formally, if you are given a list \( packets = [p_0, p_1, \ldots, p_{n-1}] \) and a list \( indices = [i_0, i_1, \ldots, i_{n-1}] \), then you should produce a new list \( result \) of size \( n \) such that \( result[i_k] = p_k \) for \( 0 \le k < n \).
It is guaranteed that \( indices \) is a permutation of \( \{0, 1, \ldots, n-1\} \).
inputFormat
The first line of input contains an integer \( n \) representing the number of packets. The second line contains \( n \) space-separated integers denoting the list of packet data. The third line contains \( n \) space-separated integers representing the indices.
\( n \) is at least 1 and \( indices \) is a permutation of \( [0, n-1] \).
outputFormat
Output a single line containing \( n \) space-separated integers, which is the reordered list of packet data.
## sample5
10 20 30 40 50
4 3 0 1 2
30 40 50 20 10