Golden Twelve Palace

xiaoxiao2021-03-06  42

[Original posted: http://acm.tongji.edu.cn/people/ps/showproblem.php?problem_id=1002&conte_id=6] qublem

In order to save Athena, Axus, Zilong, Ice, and Axi, you must have a golden tweet palace.

OUTPUT

Sample Input

4

2

1

4

3

Sample Output

twenty one

The third one they came to the Double Triar, and the Saaga of the Golden Saint Seiwei was actually a fake pope. He used his skills to put the doubles palace into a maze, with n enemies, holding an ax. (Of course, it is a phantom) Starians them four. Since the eyes of the purple dragon temporarily, he realized that this is a maze, so it is very easy to pass. The glacial and Angi have been caught in the battle. The second yuan space of the ice river was hit by the Libra Palace. At this point, there is only one alone.

However, Axi uses his nebula chain, smoothly cracking the false phase of the maze, dispelting the Gemini Saint. And that n phantom became a person. It turns out that those people are spaghetti. This n personal uses a 1..n sign, now they hold an ax in each hand. These ax are their own, but the order of the ax is chaotic, and everyone is not necessarily their own ax. This n ax also uses a 1..N mark. Now, they want an instant to think a way, use the shortest time, make them get their own ax. Every time a person can do not do any action, or exchange an ax with another person. Seeking minimal exchange and shortest time.

Input This topic includes multi-group data. Chain 1, N (2 <= n <= 20000) below N row, 1 number per row, indicating the number of the ax in the i person. For each group of data output, for two numbers, at least the number of times, and the shortest time.

转载请注明原文地址:https://www.9cbs.com/read-62403.html

New Post(0)