CF1200A.Hotelier

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

Amugae 拥有一家由 1010 个房间组成的酒店。这些房间从左到右依次编号为 00 到 99。

该酒店有两个入口——一个位于最左端,另一个位于最右端。当顾客从左侧入口进入酒店时,会被分配到距离左侧入口最近的空房间;类似地,当顾客从右侧入口进入酒店时,会被分配到距离右侧入口最近的空房间。

某天,Amugae 丢失了房间分配列表。所幸 Amugae 的记忆力极佳,他清楚地记得所有顾客的信息:每位顾客到达的时间、进入的入口,以及离开酒店的时间。初始时,酒店中所有房间均为空。请编写一个程序,根据 Amugae 的记忆恢复出房间分配列表。

输入格式

The first line consists of an integer nn (1≤n≤1051 \le n \le 10^5), 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.

第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5),表示阿木盖记忆中的事件数量。

第二行包含一个长度为 nn 的字符串,按时间顺序描述这些事件。每个字符的含义如下:

  • 'L':一名顾客从左入口进入。
  • 'R':一名顾客从右入口进入。
  • '0', '1', ..., '9':位于房间 xx(分别对应数字 00, 11, ..., 99)的顾客离开。

保证每当有顾客到达时,至少存在一个空房间;且当给出数字 xx(00, 11, ..., 99)时,房间 xx 中必定有一名顾客。此外,所有房间初始时均为空。

输出格式

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.

在唯一的一行中,输出酒店房间的分配状态,从房间 00 到房间 99。用 '0' 表示空房间,用 '1' 表示已入住房间,中间不加空格。

输入输出样例

  • 输入#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 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.

在第一个例子中,每次操作后酒店房间的分配状态如下:

  • 首先,所有房间均为空。分配状态为 0000000000。
  • L:一名顾客从左侧入口进入酒店。分配状态变为 1000000000。
  • L:又一名顾客从左侧入口进入。分配状态变为 1100000000。
  • R:又一名顾客从右侧入口进入。分配状态变为 1100000001。
  • L:又一名顾客从左侧入口进入。分配状态变为 1110000001。
  • 1:房间 11 中的顾客离开。分配状态变为 1010000001。
  • R:又一名顾客从右侧入口进入。分配状态变为 1010000011。
  • L:又一名顾客从左侧入口进入。分配状态变为 1110000011。
  • 1:房间 11 中的顾客离开。分配状态变为 1010000011。

因此,最终酒店房间的分配状态为 1010000011。

在第二个例子中,每次操作后酒店房间的分配状态如下:

  • L:一名顾客从左侧入口进入酒店。分配状态变为 1000000000。
  • 0:房间 00 中的顾客离开。分配状态变为 0000000000。
  • L:一名顾客从左侧入口进入酒店。分配状态再次变为 1000000000。
  • 0:房间 00 中的顾客离开。分配状态变为 0000000000。
  • L:一名顾客从左侧入口进入酒店。分配状态变为 1000000000。
  • L:又一名顾客从左侧入口进入。分配状态变为 1100000000。
  • R:又一名顾客从右侧入口进入。分配状态变为 1100000001。
  • R:又一名顾客从右侧入口进入。分配状态变为 1100000011。
  • 9:房间 99 中的顾客离开。分配状态变为 1100000010。

因此,最终酒店房间的分配状态为 1100000010。

输入解题思路,AI测评打分。不知道怎么写?

首页