#P7812. [JRKSJ R2] Dark Forest

    ID: 6698 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2021洛谷原创提交答案Special Judge模拟退火遗传随机贪心随机化

[JRKSJ R2] Dark Forest

题目背景

本题为提交答案题。

题目描述

给你一个长为 nn 的序列 aa,定义 1n1\dots n 的排列 pp 的权值为

i=1npiapi1apiapi+1\sum_{i=1}^n p_i a_{p_{i-1}} a_{p_i}a_{p_{i+1}}

你可以理解为这个排列是一个环,即 p0=pn,pn+1=p1p_{0}=p_n,p_{n+1}=p_1

请构造一个权值尽量大1n1\dots n 的排列。

输入格式

第一行一个整数 nn

第二行 nn 个整数表示序列 aa

输出格式

一行 nn 个整数表示排列。

5
1 4 3 2 5
1 3 5 2 4

提示

注意是 a[p[i-1]] a[p[i+1]],数据有一定梯度。

数据范围

对于 100%100\% 的数据,1n,ai1031\le n,a_i\le 10^3

样例解释

该排列的权值为 $1\times2\times1\times3+3\times1\times3\times5+5\times3\times5\times4+2\times5\times4\times2+4\times4\times2\times1=463$,可以证明这是最优的排列之一。

评分方式

本题使用 Special Judge,每个测试点都有 1010 个参数 v1,v2,v10v_1,v_2,\dots v_{10}。如果你的输出的权值 VviV\ge v_i,则该测试点您至少会获得 ii 分。

特别的,如果您的输出不是一个 1n1\dots n 的排列,您会在该测试点获得 00 分。

评分参数已经放至附件。