Hotelier
InterviewTime limit1sMemory limit256 MB
Simulate customers entering a 10-room hotel from the left or right end and leaving by room number, then print which rooms are occupied at the end.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Problem
Amugae has a hotel consisting of rooms. The rooms are numbered from to from left to right.
The hotel has two entrances, one at the left end and another at the right end. When a customer arrives through the left entrance, they are assigned to the empty room closest to the left entrance. Similarly, when a customer arrives through the right entrance, they are assigned to the empty room closest to the right entrance.
One day, Amugae lost the room assignment list. Thankfully, Amugae's memory is perfect, and he remembers every customer: when each one arrived, through 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 contains an integer (), the number of events in Amugae's memory.
The second line contains a string of length describing the events in chronological order. Each character means the following.
L: A customer arrives through the left entrance.R: A customer arrives through the right entrance.0,1, ...,9: The customer in room (, , ..., respectively) leaves.
When a customer arrives, there is always at least one empty room. When a digit is given, there is a customer in that room. Initially all rooms are empty.
Output
Print the room assignment status from room to room in one line. Write an empty room as 0 and an occupied room as 1, without spaces.
Hint
In the first example, the status after each action is as follows.
- Initially all rooms are empty. Status is
0000000000. L: A customer arrives through the left entrance. Status is1000000000.L: Another customer arrives through the left entrance. Status is1100000000.R: A customer arrives through the right entrance. Status is1100000001.L: A customer arrives through the left entrance. Status is1110000001.1: The customer in room leaves. Status is1010000001.R: A customer arrives through the right entrance. Status is1010000011.L: A customer arrives through the left entrance. Status is1110000011.1: The customer in room leaves. Status is1010000011.
So the final status is 1010000011.
In the second example, the status after each action is as follows.
L: A customer arrives through the left entrance. Status is1000000000.0: The customer in room leaves. Status is0000000000.L: A customer arrives through the left entrance. Status is1000000000again.0: The customer in room leaves. Status is0000000000.L: A customer arrives through the left entrance. Status is1000000000.L: Another customer arrives through the left entrance. Status is1100000000.R: A customer arrives through the right entrance. Status is1100000001.R: Another customer arrives through the right entrance. Status is1100000011.9: The customer in room leaves. Status is1100000010.
So the final status is 1100000010.