1. 程式人生 > >【CodeForces - 1200A】Hotelier(水題、模擬)

【CodeForces - 1200A】Hotelier(水題、模擬)

Hotelier

直接翻譯了

Descriptions

Amugae的酒店由10人組成10客房。房間從0開始編號0到99 從左到右。

酒店有兩個入口 - 一個來自左端,另一個來自右端。當顧客通過左入口到達酒店時,他們被分配到最靠近左入口的空房間。類似地,當顧客通過右入口到達酒店時,他們被分配到最靠近右入口的空房間。

有一天,Amugae失去了房間分配清單。值得慶幸的是,Amugae的記憶非常完美,他記得所有顧客:當顧客到達時,從哪個入口到他們離開酒店。最初酒店是空的。編寫一個程式,從Amugae的記憶中恢復房間分配列表。

Input

第一行由整陣列成 ññ (1≤n≤1051≤ñ≤105),Amugae記憶中的事件數量。

第二行由一串長度組成 ññ按時間順序描述事件。每個字元代表:

  • ' L ':顧客從左入口到達。
  • ' R ':客戶從右入口到達。
  • ' 0 ',' 1 ',...,' 9 ':房間裡的顧客從X (0, 1, ..., 9 )房間離開。

保證客戶到達時至少有一個空房間,房間裡有一個顧客 X 什麼時候 X (0, 1, ..., 9) 給出。此外,所有房間最初都是空的。

Output

在唯一的一行,從房間輸出酒店房間的分配狀態 00 到房間 99。將空房間表示為“ 0 ”,將佔用的房間表示為“ 1 ”,不帶空格。

Examples

Input
8
LLRL1RL1
Output
1010000011
Input
9
L0L0LLRR9
Output
1100000010

題目連結

https://vjudge.net/problem/CodeForces-1200A

 

簽到題 模擬一遍即可

 

AC程式碼

 

#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>1
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define Mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define Maxn 100005
using namespace std;
int n;
string s,op;
int main()
{
    s="0000000000";
    cin>>n;
    cin>>op;
    for(int i=0; i<op.length(); i++)
    {
        if(op[i]=='L')
        {
            for(int i=0; i<10; i++)
            {
                if(s[i]=='0')
                {
                    s[i]='1';
                    break;
                }
            }
        }
        else if(op[i]=='R')
        {
            for(int i=9; i>=0; i--)
            {
                if(s[i]=='0')
                {
                    s[i]='1';
                    break;
                }
            }
        }
        else
        {
            int pos=op[i]-'0';
            s[pos]='0';
        }
    }
    cout<<s<<endl;
    return 0;
}