QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100
الإحصائيات

如果一个 $0, 1, \dots, n-1$ 的排列 $a_0, a_1, \dots, a_{n-1}$ 满足由 $b_i = |a_i - i|$ 定义的序列 $b_0, \dots, b_{n-1}$ 同样是 $0, \dots, n-1$ 的一个排列,则称该排列为“优美”的。

给定 $n$,构造一个 $n$ 个元素的优美排列,或者确定其不存在。

第一行包含一个整数 $n$ ($1 \le n \le 10^6$):排列的大小。

如果不存在 $n$ 个元素的优美排列,输出一行单词 “NO”。

否则,在第一行输出 “YES”,并在第二行输出 $n$ 个空格分隔的整数 $a_0, \dots, a_{n-1}$:即该优美排列。如果存在多个优美排列,输出其中任意一个即可。

样例

输入格式 1

4

输出格式 1

YES
3 0 2 1

输入格式 2

3

输出格式 2

NO

输入格式 3

1

输出格式 3

YES
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.