QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#7346. 青蛙

统计

有 $n$ 只青蛙坐在一条直线上的 $n$ 块岩石上。每块岩石上恰好有一只青蛙。岩石(以及青蛙)按其在直线上的位置顺序,由 $1$ 到 $n$ 的连续整数编号。

青蛙们有一个统治世界的秘密计划,涉及它们同时进行跳跃,使得跳跃后每块岩石上仍然恰好有一只青蛙。记第 $i$ 只青蛙的目标岩石为 $p_i$。有些青蛙可能原地跳跃,即 $p_i$ 可能等于 $i$。

天空中有一颗卫星在追踪青蛙的移动。由于技术原因,它只追踪处于运动状态的目标。因此,它提供的信息如下:对于岩石之间的 $n-1$ 个区间,已知有多少只青蛙跨越了该区间(无论方向如何)。

青蛙们按照上述方式跳跃了一次。请找出满足观测到的 $n-1$ 个跨越次数的任意序列 $p_i$。

输入格式

第一行包含一个整数 $n$,表示青蛙的数量 ($2 \le n \le 200\,000$)。

第二行包含 $n-1$ 个空格分隔的整数 $a_1, \dots, a_{n-1}$ ($0 \le a_i \le 200\,000$),其中第 $i$ 个数表示跨越岩石 $i$ 和 $i+1$ 之间区间的青蛙数量。

输出格式

如果不存在满足条件的排列,输出 “No”(不含引号)。

否则,在第一行输出 “Yes”。在第二行输出 $n$ 个整数 $p_1, p_2, \dots, p_n$,使得如果青蛙按照该序列跳跃,每块岩石上仍然恰好有一只青蛙,且所有岩石间区间的跨越次数与给定值一致。如果存在多种可能的答案,输出其中任意一个即可。

样例

样例输入 1

5
2 4 2 2

样例输出 1

Yes
4 3 2 5 1

样例输入 2

4
1 2 3

样例输出 2

No

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.