0% found this document useful (0 votes)
1K views1 page

482 Permutation Arrays: Input

The document describes problem 482 from the ACM Contest Problems Archive. It involves permuting data arrays by specifying permutations with an index array, where the permuted array x is equal to the original array x with its elements ordered according to the index array. The input contains an index array specifying a permutation and a list of floating point numbers. The output reorders the list of numbers according to the permutation in the index array, printing each number on its own line.

Uploaded by

xartemisx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views1 page

482 Permutation Arrays: Input

The document describes problem 482 from the ACM Contest Problems Archive. It involves permuting data arrays by specifying permutations with an index array, where the permuted array x is equal to the original array x with its elements ordered according to the index array. The input contains an index array specifying a permutation and a list of floating point numbers. The output reorders the list of numbers according to the permutation in the index array, printing each number on its own line.

Uploaded by

xartemisx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ACM Contest Problems Archive

University of Valladolid (SPAIN)

482 Permutation Arrays


In many computer problems, it is necessary to permute data arrays. That is, the data in an array must
be re-arranged in some speci ed order. One way to permute arbitrary data arrays is to specify the
permutations with an index array. Let x be an array that is to be permuted and let x be the permuted
array. Then, we have the relationship between x and x that x = x .
0

pi

Input

The input le will contain two lines of numbers. The rst line will be an index array containing the
integers 1 : : : n, where n is the number of integers in the list. The numbers in the rst line will have been
permuted in some fashion. The second line will contain a list numbers in oating point format.

Output

The output for this program will be the list of oating point numbers from the input le, ordered
according to the permutation array from the input le. The output numbers must be printed one per
line in the same format in which they each appeared in the input le.

Sample Input
3 1 2
32.0 54.7 -2

Sample Output
-2
32.0
54.7

You might also like