CF622D.Optimal Number Permutation

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a.

Let number i be in positions x__i, y__i (x__i < y__i) in the permuted array a. Let's define the value d__i = y__i - x__i — the distance between the positions of the number i. Permute the numbers in array a to minimize the value of the sum .

你有一个数组 $ a $,其中包含从 $ 1 $ 到 $ n $ 的每个整数各两次。你可以对数组 $ a $ 中的元素进行任意重排。

设数字 $ i $ 在重排后的数组 $ a $ 中位于位置 $ x_i $ 和 $ y_i $(满足 $ x_i < y_i $)。我们定义 $ d_i = y_i - x_i $,即数字 $ i $ 的两个出现位置之间的距离。请重排数组 $ a $,使得和式

的值最小。

输入格式

The only line contains integer n (1 ≤ n ≤ 5·105).

唯一的一行包含一个整数 nn(1 ≤ n ≤ 5⋅1051 \leq n \leq 5\cdot10^5)。

输出格式

Print 2_n_ integers — the permuted array a that minimizes the value of the sum s.

输出 2n2n 个整数——即使得和 ss 的值最小的排列后的数组 aa。

输入输出样例

  • 输入#1

    2

    输出#1

    1 1 2 2
  • 输入#2

    1

    输出#2

    1 1

输入解题思路,AI测评打分。不知道怎么写?

首页