A - Hotelier

Amugae has a hotel consisting of 1010 rooms. The rooms are numbered from 00 to 99 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 nn (1 \le n \le 10^51≤n≤105), the number of events in Amugae's memory.

The second line consists of a string of length nn 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 xx (00, 11, ..., 99 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 xx when xx (00, 11, ..., 99) is given. Also, all the rooms are initially empty.

Output

In the only line, output the hotel room's assignment status, from room 00 to room 99. Represent an empty room as '0', and an occupied room as '1', without spaces.

Examples

Input

8
LLRL1RL1

Output

1010000011

Input

9
L0L0LLRR9

Output

1100000010

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 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 11 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 11 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 00 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 00 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 99 leaves. Assignment status is 1100000010.

So after all, hotel room's final assignment status is 1100000010.

#include<iostream>
using namespace std;
#include<string>
#include<algorithm>
#pragma warning (disable:4996)
#include <climits>
#include <vector>
bool book[10];
int main() {
	int n;
	cin >> n;
	getchar();
	for (int cnt = 0; cnt < n; cnt++) {
		char temp = getchar();
		if (temp >= '0' && temp <= '9')
			book[temp - '0'] = 0;
		if (temp == 'L') {
			for (int cnt1 = 0; cnt1 < n; cnt1++) {
				if (!book[cnt1]) {
					book[cnt1] = 1;
					break;
				}
			}
		}
		if (temp == 'R') {
			for (int cnt1 = 9; cnt1 >= 0; cnt1--) {
				if (!book[cnt1]) {
					book[cnt1] = 1;
					break;
				}
			}
		}
	}
	for (int cnt = 0; cnt < 10; cnt++) {
		cout << book[cnt];
	}
	return 0;
}

说实话吗,这道题我卡住了,因为我提前没注意到它的数据大小是n只有10.............

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cjz-lxg

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值