No.1537 Please Do My Job for Me.
タグ : / 解いたユーザー数 47
作問者 :
pepper_aobuta
/ テスター :
57tggx
logx
とりゐ
Problem Statement
The Kingdom of Yuyu has $N$ cities $1,2,...,N$. City $1$ is the royal capital, where King Yuyu lives. The Kingdom of Yuyu also has $N$ distinct positive integers $A_1,A_2,...,A_N$ handed down through the generations.
Any $2$ cities in the Kingdom of Yuyu are connected by a road, and the length of the road connecting cities $i,j$ $(1\leq i < j\leq N)$ is $A_i\times A_j[\mathrm{m}]$.
Now, today is King Yuyu's birthday. Every year on the king's birthday, the king visits all the cities in the country. The kind-hearted King Yuyu wants to travel as long a distance as possible in order to show himself to more of his people. King Yuyu has entrusted me with planning the route of this trip, but I cannot figure out which route, among those that start from city $1$, pass through every city exactly once, and return to city $1$, has the maximum travel distance. So, please work out such a route for me.
Input
$N$ $A_1\ A_2\ ... \ A_N$
Output
Output the numbers of the cities in the order they are visited, separated by single-byte spaces.For example, if the answer is the route that starts from city $1$, passes through cities $3,5,7,6,4,2$ in this order, and returns to $1$, output
1 3 5 7 6 4 2 1
If there are multiple answers, any of them will be accepted.
Sample
Sample 1
Input
2 1 2
Output
1 2 1
Do not forget to output $1$ at the beginning and at the end.
Sample 2
Input
3 1 4 12
Output
1 3 2 1
Outputting 1 2 3 1 is also accepted.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。