#C962. Restore the Shuffled String
Restore the Shuffled String
Restore the Shuffled String
Given a string s and an array of indices, the task is to restore the original order of characters after they have been shuffled. The new position for each character is specified by the corresponding element in the indices array.
Formally, if s is a string of length n and indices is an array of size n, then the character originally at position i in s should be moved to position indices[i] in the resulting string. For example, if s = "abc" and indices = [2, 1, 0], then the output should be "cba".
This can be written mathematically as:
$$ res[indices[i]] = s[i] \quad \text{for } i = 0, 1, \dots, n-1. $$
inputFormat
The first line contains a string s. The second line contains space-separated integers representing the new positions for each character in s. The number of integers will be exactly equal to the length of s.
outputFormat
Print the restored string to standard output.## sample
abc
2 1 0
cba