P7812 [JRKSJ R2] Dark Forest
Background
**This is an output-only problem.**
Description
You are given a sequence $a$ of length $n$. Define the weight of a permutation $p$ of $1 \dots n$ as
$$\sum_{i=1}^n p_i a_{p_{i-1}} a_{p_i}a_{p_{i+1}}$$
You may treat this permutation as a cycle, i.e., $p_{0}=p_n, p_{n+1}=p_1$.
Please construct a permutation of $1 \dots n$ with the weight as **large as possible**.
Input Format
The first line contains an integer $n$.
The second line contains $n$ integers representing the sequence $a$.
Output Format
Output one line with $n$ integers representing the permutation.
Explanation/Hint
Note that it is `a[p[i-1]] a[p[i+1]]`. The testdata has some gradation.
### Constraints
For $100\%$ of the testdata, $1 \le n, a_i \le 10^3$.
### Sample Explanation
The weight of this permutation is $1\times2\times1\times3+3\times1\times3\times5+5\times3\times5\times4+2\times5\times4\times2+4\times4\times2\times1=463$. It can be proven that this is one of the optimal permutations.
### Scoring
**This problem uses Special Judge.** Each test point has $10$ parameters $v_1, v_2, \dots v_{10}$. If the weight of your output is $V \ge v_i$, then on that test point you will get at least $i$ points.
In particular, if your output is not a permutation of $1 \dots n$, you will get $0$ points on that test point.
The scoring parameters have been provided in the attachment.
Translated by ChatGPT 5