欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1200A.Hotelier
Hotelier
Amugae has a hotel consisting of rooms. The rooms are numbered from to from left to right.
The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similarly, when a customer arrives at the hotel through the right entrance, they are assigned to an empty room closest to the right entrance.
One day, Amugae lost the room assignment list. Thankfully Amugae's memory is perfect, and he remembers all of the customers: when a customer arrived, from which entrance, and when they left the hotel. Initially the hotel was empty. Write a program that recovers the room assignment list from Amugae's memory.
Input
The first line consists of an integer (), the number of events in Amugae's memory.
The second line consists of a string of length describing the events in chronological order. Each character represents:
- '
L': A customer arrives from the left entrance. - '
R': A customer arrives from the right entrance. - '
0', '1', ..., '9': The customer in room (, , ..., respectively) leaves.
It is guaranteed that there is at least one empty room when a customer arrives, and there is a customer in the room when (, , ..., ) is given. Also, all the rooms are initially empty.
Output
In the only line, output the hotel room's assignment status, from room to room . Represent an empty room as '0', and an occupied room as '1', without spaces.
Note
In the first example, hotel room's assignment status after each action is as follows.
- First of all, all rooms are empty. Assignment status is
0000000000. L: a customer arrives to the hotel through the left entrance. Assignment status is1000000000.L: one more customer from the left entrance. Assignment status is1100000000.R: one more customer from the right entrance. Assignment status is1100000001.L: one more customer from the left entrance. Assignment status is1110000001.1: the customer in room leaves. Assignment status is1010000001.R: one more customer from the right entrance. Assignment status is1010000011.L: one more customer from the left entrance. Assignment status is1110000011.1: the customer in room leaves. Assignment status is1010000011.
So after all, hotel room's final assignment status is 1010000011.
In the second example, hotel room's assignment status after each action is as follows.
L: a customer arrives to the hotel through the left entrance. Assignment status is1000000000.0: the customer in room leaves. Assignment status is0000000000.L: a customer arrives to the hotel through the left entrance. Assignment status is1000000000again.0: the customer in room leaves. Assignment status is0000000000.L: a customer arrives to the hotel through the left entrance. Assignment status is1000000000.L: one more customer from the left entrance. Assignment status is1100000000.R: one more customer from the right entrance. Assignment status is1100000001.R: one more customer from the right entrance. Assignment status is1100000011.9: the customer in room leaves. Assignment status is1100000010.
So after all, hotel room's final assignment status is 1100000010.
Samples
8
LLRL1RL1
1010000011
9
L0L0LLRR9
1100000010
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |