QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 2048 MB Total points: 100

#10317. Statues

统计

一位市长想要在城市各路口放置 $n$ 座雕像。城市中的路口位于所有坐标为整数的点 $(x, y)$ 上。路口之间的距离使用曼哈顿距离衡量,定义如下:

$$\text{distance}((x_1, y_1), (x_2, y_2)) = |x_1 - x_2| + |y_1 - y_2|.$$

市议会针对雕像的放置提出了以下要求:

  • 第一座雕像放置在 $(0, 0)$;
  • 第 $n$ 座雕像放置在 $(a, b)$;
  • 对于 $i = 1, \dots, n - 1$,第 $i$ 座雕像与第 $i + 1$ 座雕像之间的距离为 $d_i$。

允许在同一个路口放置多座雕像。 请帮助市长找到一种合法的 $n$ 座雕像放置方案,或者确定其不存在。

输入格式

第一行包含一个整数 $n$ ($3 \le n \le 50$) —— 雕像的数量。 第二行包含两个整数 $a$ 和 $b$ ($0 \le a, b \le 10^9$) —— 第 $n$ 座雕像必须放置的路口坐标。 第三行包含 $n - 1$ 个整数 $d_1, \dots, d_{n-1}$ ($0 \le d_i \le 10^9$) —— 第 $i$ 座雕像与第 $i + 1$ 座雕像之间的距离。

输出格式

如果存在合法的 $n$ 座雕像放置方案,输出 YES。否则,输出 NO。 如果存在合法的方案,请在接下来的 $n$ 行中打印该方案。其中第 $i$ 行应包含两个整数 $x_i$ 和 $y_i$ —— 第 $i$ 座雕像放置的路口坐标。如果存在多种方案,你可以打印其中任意一种。

样例

输入 1

3
5 8
9 0

输出 1

NO

说明 1

不存在 3 座雕像的合法放置方案。

输入 2

4
10 6
7 8 5

输出 2

YES
0 0
6 -1
11 2
10 6

说明 2

样例输出如下图所示。注意,这并不是 4 座雕像唯一的合法放置方案。

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.