Back to problems Sign in to unlock
Codeforces
Easy
Arrays
Presents
Given a permutation describing who gave a present to whom, reconstruct the final arrangement so that each child gets the present intended for them.
Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement
Problem
There are children numbered from $1npnp_iip_i$.
Your task is to determine, for every child , which child gave a present to them.
In other words, output the inverse permutation.
Task
For each child from $1njp_j = i$.
Input Format
- The first line contains an integer .
- The second line contains integers — a permutation of $1..n$.
Output Format
- Print integers where is the child who gave a present to child .
Constraints
- is a permutation of $1..n$
- Time limit friendly solution:
Examples
Sample cases returned by the problem API.
Example 1
Input
4 2 3 4 1
Output
4 1 2 3
Explanation
Child 1 received a present from child 4, child 2 from child 1, child 3 from child 2, and child 4 from child 3.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.