Universal Cup Judging System

Universal Cup

时间限制: 1.0 s 内存限制: 512 MB 总分: 100 难度: [显示] 可 Hack ✓
统计

Denis 非常喜欢数字的二进制表示。有一次,他将 1 到 7 的二进制表示按某种顺序一个接一个地写下来,并使它们的最右侧数位对齐。随后他发现,这些数字中的 1 构成了一个单一的连通区域:如果我们把每个数位看作网格中的方格,那么所有包含 1 的方格通过边相连。现在他想知道,对于不同的 $n$,是否也能对 1 到 $n$ 的数字做到这一点。

给定一个整数 $n$。你需要找到 1 到 $n$ 的所有整数的一个好排列,或者确定不存在这样的排列。如果一个排列满足以下条件,则称其为“好”的:当我们按上述方式写下这些数字时,所有的 1 构成一个单一的连通区域。

输入格式

仅一行,包含一个整数 $n$ ($1 \le n \le 2 \cdot 10^5$)。

输出格式

如果不存在这样的好排列,输出一行 “NO”(大写)。 否则,输出一行 “YES”(大写),并在下一行输出你找到的好排列。如果存在多种可能的答案,输出其中任意一个即可。

样例

样例输入 1

1

样例输出 1

YES
1

样例输入 2

2

样例输出 2

NO

样例输入 3

3

样例输出 3

YES
2 3 1

说明

第三个样例

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#522Editorial Open集训队作业 解题报告 by 刘家炜Qingyu2026-01-02 21:39:27 Download

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.