<PREV Problem:
NEXT>
Solved by 126 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Square root of permutation

Time limit = 2 second(s)

Permutation of numbers 1,2 ... N is given. Please found out any permutation X that gives A if applied twice:

X * X = A

Input In the first line N is given, 0 < N < 10001. In the second line permutation A is given. Permutation "4 1 2 3" means the number 4 from 4th place goes to the first, 1 goes to the second place, 2 goes to the third place, 3 goes to the fourth place.

Output If there is no proper X then output 0. Otherwise output N numbers describing permutaion X (one of the possible).

Input#1
4
2 3 4 1
Output#1
0

Input#2
4
3 4 1 2
Output#2
2 3 4 1


Author:
Voroztsov Artem, MIPT Contest 3 October 2004 sponsored by NIX
3 October 2004

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 54.158.248.167