QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 256 MB 总分: 100

#11622. 多彩的门

统计

有一座桥连接着河流的左岸和右岸。桥上在不同位置放置了 $2N$ 扇门,并涂有不同的颜色。门的颜色用 $1$ 到 $N$ 的整数表示。对于每个 $k$ ($1 \le k \le N$),恰好有两扇门涂有颜色 $k$。

Snuke 决定从左岸走到右岸。他会一直向右走,但在行走过程中会发生以下事件: 当 Snuke 触碰到一扇颜色为 $k$ ($1 \le k \le N$) 的门时,他会瞬间移动到另一扇颜色为 $k$ 的门的右侧。

可以证明他最终一定会到达右岸。

对于每个 $i$ ($1 \le i \le 2N - 1$),将第 $i$ 扇门和第 $i+1$ 扇门之间的区域称为第 $i$ 段。在过桥后,Snuke 记录了他是否走过了第 $i$ 段,对于每个 $i$ ($1 \le i \le 2N - 1$)。该记录以长度为 $2N - 1$ 的字符串 $s$ 的形式给出。对于每个 $i$ ($1 \le i \le 2N - 1$),如果 Snuke 走过了第 $i$ 段,则 $s$ 的第 $i$ 个字符为 '1';否则,第 $i$ 个字符为 '0'。

请判断是否存在一种符合该记录的门的排列方式。如果存在,请构造出其中一种排列。

输入格式

输入按以下格式给出: $N$ $s$

数据范围: $N$ 为整数,$(1 \le N \le 10^5)$,$s$ 由 '0' 和 '1' 组成,$|s| = 2N - 1$。

输出格式

如果不存在符合记录的门的排列,输出 “No”。如果存在,第一行输出 “Yes”,第二行输出一种排列,格式如下:$c_1 \ c_2 \ \dots \ c_{2N}$。其中,对于每个 $i$ ($1 \le i \le 2N$),$c_i$ 表示从左往右数第 $i$ 扇门的颜色。

样例

样例输入 1

2
010

样例输出 1

Yes
1 1 2 2

样例输入 2

2
001

样例输出 2

No

样例输入 3

3
10110

样例输出 3

Yes
1 3 2 1 2 3

样例输入 4

3
10101

样例输出 4

No

样例输入 5

6
00111011100

样例输出 5

Yes
1 6 1 2 3 4 4 2 3 5 6 5

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#559Editorial Open集训队作业 解题报告 by 胡晓虎Qingyu2026-01-02 22:21:50 Download
#556Editorial Open集训队作业 解题报告 by 叶隽霖Qingyu2026-01-02 22:20:43 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.