A12850 | Hotelier
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Amugae has a hotel consisting of $10$ rooms. The rooms are numbered from $0$ to $9$ 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.
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.
输入格式
The first line consists of an integer $n$ ( $1 \le n \le 10^5$ ), the number of events in Amugae's memory.
The second line consists of a string of length $n$ 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 $x$ ( $0$ , $1$ , ..., $9$ 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 $x$ when $x$ ( $0$ , $1$ , ..., $9$ ) is given. Also, all the rooms are initially empty.
The second line consists of a string of length $n$ 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 $x$ ( $0$ , $1$ , ..., $9$ 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 $x$ when $x$ ( $0$ , $1$ , ..., $9$ ) is given. Also, all the rooms are initially empty.
输出格式
In the only line, output the hotel room's assignment status, from room $0$ to room $9$ . Represent an empty room as '0', and an occupied room as '1', without spaces.
输入输出样例
输入 #1
8 LLRL1RL1
输出 #1
1010000011
输入 #2
9 L0L0LLRR9
输出 #2
1100000010
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 is 1000000000.
- L: one more customer from the left entrance. Assignment status is 1100000000.
- R: one more customer from the right entrance. Assignment status is 1100000001.
- L: one more customer from the left entrance. Assignment status is 1110000001.
- 1: the customer in room $1$ leaves. Assignment status is 1010000001.
- R: one more customer from the right entrance. Assignment status is 1010000011.
- L: one more customer from the left entrance. Assignment status is 1110000011.
- 1: the customer in room $1$ leaves. Assignment status is 1010000011.
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 is 1000000000.
- 0: the customer in room $0$ leaves. Assignment status is 0000000000.
- L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000 again.
- 0: the customer in room $0$ leaves. Assignment status is 0000000000.
- L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.
- L: one more customer from the left entrance. Assignment status is 1100000000.
- R: one more customer from the right entrance. Assignment status is 1100000001.
- R: one more customer from the right entrance. Assignment status is 1100000011.
- 9: the customer in room $9$ leaves. Assignment status is 1100000010.
So after all, hotel room's final assignment status is 1100000010.
- First of all, all rooms are empty. Assignment status is 0000000000.
- L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.
- L: one more customer from the left entrance. Assignment status is 1100000000.
- R: one more customer from the right entrance. Assignment status is 1100000001.
- L: one more customer from the left entrance. Assignment status is 1110000001.
- 1: the customer in room $1$ leaves. Assignment status is 1010000001.
- R: one more customer from the right entrance. Assignment status is 1010000011.
- L: one more customer from the left entrance. Assignment status is 1110000011.
- 1: the customer in room $1$ leaves. Assignment status is 1010000011.
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 is 1000000000.
- 0: the customer in room $0$ leaves. Assignment status is 0000000000.
- L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000 again.
- 0: the customer in room $0$ leaves. Assignment status is 0000000000.
- L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.
- L: one more customer from the left entrance. Assignment status is 1100000000.
- R: one more customer from the right entrance. Assignment status is 1100000001.
- R: one more customer from the right entrance. Assignment status is 1100000011.
- 9: the customer in room $9$ leaves. Assignment status is 1100000010.
So after all, hotel room's final assignment status is 1100000010.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted