QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 2048 MB 満点: 100

#14570. Karlsruhe Skyline

統計

“数独摩天楼”(Skyscrapers)是一种网格逻辑谜题,其中数字 $1$ 到 $n$ 必须填入一个 $n \times n$ 的网格中。每个数字在每行和每列中都必须恰好出现一次。这些数字可以看作是对应高度单位的摩天大楼。行和列的两端可能会有提示数字,表示从该位置沿行或列看过去时能看到的摩天大楼数量,其中较高的建筑物会挡住其后面较矮的建筑物。

图 K.1:样例输出 1 的示意图。从左边可以看到两栋建筑物(1 和 5),从右边可以看到两栋建筑物(4 和 5)。

在本题中,我们只考虑“数独摩天楼”网格中的单单一整行,该行的两端都有提示数字。请判断是否可以将高度为 $1$ 到 $n$ 的摩天大楼放入该行中以同时满足两端的提示,如果可以,请给出一种合法的放置方案。

输入格式

输入包含:

  • 一行,包含三个整数 $n$、$a$ 和 $b$($2 \le n \le 1000$,$1 \le a, b \le n$),分别表示该行的长度以及左侧和右侧的提示数字。

输出格式

如果存在合法的放置方案,输出 yes,随后输出 $n$ 个互不相同的整数 $h_1, \dots, h_n$(对于每个 $i$,满足 $1 \le h_i \le n$),表示从左到右的建筑物高度。

如果存在多种合法的解,你可以输出其中任意一种。

如果不存在合法的放置方案,输出 no

样例

输入样例 1

5 2 2

输出样例 1

yes
1 5 2 3 4

输入样例 2

5 3 4

输出样例 2

no

输入样例 3

10 3 4

输出样例 3

yes
4 1 8 5 3 10 6 9 7 2

输入样例 4

4 1 4

输出样例 4

yes
4 3 2 1

输入样例 5

9 1 1

输出样例 5

no

输入样例 6

6 2 1

输出样例 6

yes
5 3 1 2 4 6

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.