<PREV Problem:
NEXT>
Solved by 126 users: ...
UserDateAttemptTimeCMSC
sokolov09 dec 2011C++901.45186 
igor.a.ehrlich14 sep 2011C++201.43190 
adamant19 feb 2015C++401.49190 
dzhavaharnal24 aug 2016C++201.51190 
Erzhan1510 mar 2012C++101.57190 
kroshka_kartoshka10 aug 2015C++701.58190 
Cthulhu21 apr 2006Ruby100.12197 
bush21 apr 2006Ruby100.11199 
Nikiror30 apr 2015C++201.46241 
topspin10 jun 2009Kylix1002.00246 
Languages
C++
87
FPC
14
Kylix
12
C
7
Java
6
Ruby
2
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

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 190ms

SW soft NIX
ID = 34.228.143.13