#P9578. 「Cfz Round 1」Permutation

    ID: 10530 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学洛谷原创Special JudgeO2优化构造洛谷月赛Ad-hoc

「Cfz Round 1」Permutation

Background

1+2+3++n=n×(n+1)21+2+3+\cdots+n=\dfrac {n\times (n+1)} 2

Problem Description

Given a positive integer nn.

We define that, for a permutation {xn}\{x_n\} of 11 to nn, $f(\{x_n\})=\max\limits_{i=1}^{n}(x_i+x_{(i \bmod n)+1})-\min\limits_{i=1}^{n}(x_i+x_{(i \bmod n)+1})$.

You need to construct a permutation {pn}\{p_n\} of 11 to nn such that for any permutation {qn}\{q_n\} of 11 to nn, we have f({pn})f({qn})f(\{p_n\})\le f(\{q_n\}), and output the permutation {pn}\{p_n\} you constructed.

Input Format

A positive integer nn.

Output Format

Output nn integers, representing the permutation {pn}\{p_n\} you constructed, separated by spaces.

Any output that satisfies the condition will be accepted.

4
1 4 2 3

Hint

Sample Explanation #1

f({1,4,2,3})=2f(\{1,4,2,3\})=2. It can be proven that for any permutation {qn}\{q_n\} of 11 to nn, we have f({1,4,2,3})f({qn})f(\{1,4,2,3\})\le f(\{q_n\}).

Of course, {1,3,2,4}\{1,3,2,4\}, {3,1,4,2}\{3,1,4,2\}, {4,1,3,2}\{4,1,3,2\}, etc. are also valid permutations {pn}\{p_n\}.

Constraints

For all testdata, 3n1063 \le n \le 10^6.

This problem uses bundled tests.

Subtask ID Points nn \le Special Property
11 2020 88 None
22 2525 10610^6 Guaranteed n0(mod2)n \equiv 0 \pmod 2
33 Guaranteed n1(mod2)n \equiv 1 \pmod 2
44 3030 None

Translated by ChatGPT 5