QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100

#17527. 观光路线

Statistiques

UCPC 王国有一条环形旅游路线,由 $N$ 个路段组成,可以环绕整个王国。每个路段都有一辆前往下一个路段的穿梭巴士。对于 $1 \leq i < N$,可以从第 $i$ 个路段前往第 $i+1$ 个路段;从第 $N$ 个路段可以前往第 $1$ 个路段。

现在有 $N$ 名来自北极的游客计划利用这条旅游路线参观 UCPC 王国。第 $i$ 名游客从第 $i$ 个路段开始,乘坐穿梭巴士总共参观 $N$ 个路段。

每个路段要么是雪原,要么是沙漠。每名游客在起点处的初始好感度为 $1$。每经过一个雪原路段,好感度增加 $1$;每经过一个沙漠路段,好感度减少 $1$。如果游客在参观过程中好感度变为 $0$,则会立即停止参观并离开。如果游客参观完所有 $N$ 个路段后好感度仍大于或等于 $1$,则该游客会购买 UCPC 王国的昂贵纪念品,然后返回自己的国家。

居住在北极的你需要根据每名游客是否购买了纪念品的信息,推断出 UCPC 王国旅游路线的结构。给定从 $1$ 到 $N$ 号游客的纪念品购买情况,请输出一种可能的旅游路线结构。

输入格式

第一行包含一个整数 $N$,表示旅游路线的路段数。$(1 \leq N \leq 500\,000)$

第二行包含一个长度为 $N$ 的字符串,表示第 $i$ 名游客是否购买了纪念品。第 $i$ 个字符表示第 $i$ 名游客的情况:如果购买了纪念品则为 O,否则为 X

输出格式

如果存在符合给定输入的 UCPC 王国旅游路线,则第一行输出 YES,第二行输出一个长度为 $N$ 的字符串。其中第 $i$ 个字符表示第 $i$ 个路段的类型:如果是雪原则输出 +,如果是沙漠则输出 -

如果不存在符合给定输入的旅游路线,则第一行输出 NO

样例

输入格式 1

5
OXOXO

输出格式 1

YES
+-+-+

输入格式 2

6
XXXXXX

输出格式 2

YES
+--+--

输入格式 3

5
XXXOX

输出格式 3

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.