CF1907B.YetnotherrokenKeoard

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Polycarp has a problem — his laptop keyboard is broken.

Now, when he presses the 'b' key, it acts like an unusual backspace: it deletes the last (rightmost) lowercase letter in the typed string. If there are no lowercase letters in the typed string, then the press is completely ignored.

Similarly, when he presses the 'B' key, it deletes the last (rightmost) uppercase letter in the typed string. If there are no uppercase letters in the typed string, then the press is completely ignored.

In both cases, the letters 'b' and 'B' are not added to the typed string when these keys are pressed.

Consider an example where the sequence of key presses was "ARaBbbitBaby". In this case, the typed string will change as follows: "" →A\xrightarrow{\texttt{A}} "A" →R\xrightarrow{\texttt{R}} "AR" →a\xrightarrow{\texttt{a}} "ARa" →B\xrightarrow{\texttt{B}} "Aa" →b\xrightarrow{\texttt{b}} "A" →b\xrightarrow{\texttt{b}} "A" →i\xrightarrow{\texttt{i}} "Ai" →t\xrightarrow{\texttt{t}} "Ait" →B\xrightarrow{\texttt{B}} "it" →a\xrightarrow{\texttt{a}} "ita" →b\xrightarrow{\texttt{b}} "it" →y\xrightarrow{\texttt{y}} "ity".

Given a sequence of pressed keys, output the typed string after processing all key presses.

波利卡普遇到了一个问题——他的笔记本电脑键盘坏了。

现在,当他按下 'b' 键时,该键的行为类似于一种特殊的退格键:它会删除已输入字符串中最后一个(最右侧的)小写字母。如果已输入字符串中没有小写字母,则此次按键将被完全忽略。

类似地,当他按下 'B' 键时,该键会删除已输入字符串中最后一个(最右侧的)大写字母。如果已输入字符串中没有大写字母,则此次按键将被完全忽略。

在上述两种情况下,字母 'b' 和 'B' 本身不会被添加到已输入字符串中。

考虑一个例子:按键序列为 "ARaBbbitBaby"。此时,已输入字符串的变化过程如下:
"" →A\xrightarrow{\texttt{A}} "A" →R\xrightarrow{\texttt{R}} "AR" →a\xrightarrow{\texttt{a}} "ARa" →B\xrightarrow{\texttt{B}} "Aa" →b\xrightarrow{\texttt{b}} "A" →b\xrightarrow{\texttt{b}} "A" →i\xrightarrow{\texttt{i}} "Ai" →t\xrightarrow{\texttt{t}} "Ait" →B\xrightarrow{\texttt{B}} "it" →a\xrightarrow{\texttt{a}} "ita" →b\xrightarrow{\texttt{b}} "it" →y\xrightarrow{\texttt{y}} "ity"。

给定一个按键序列,请输出处理完所有按键后得到的最终字符串。

输入格式

The first line of the input data contains an integer tt (1≤t≤10001 \le t \le 1000), the number of test cases in the test.

The following contains tt non-empty lines, which consist of lowercase and uppercase letters of the Latin alphabet.

It is guaranteed that each line contains at least one letter and the sum of the lengths of the lines does not exceed 10610^6.

输入数据的第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。

接下来的 tt 行为非空行,每行由拉丁字母的小写和大写字母组成。

保证每行至少包含一个字母,且所有行的长度总和不超过 10610^6。

输出格式

For each test case, output the result of processing the key presses on a separate line. If the typed string is empty, then output an empty line.

对于每个测试用例,在单独一行中输出按键处理后的结果。如果输入的字符串为空,则输出一个空行。

输入输出样例

  • 输入#1

    12
    ARaBbbitBaby
    YetAnotherBrokenKeyboard
    Bubble
    Improbable
    abbreviable
    BbBB
    BusyasaBeeinaBedofBloomingBlossoms
    CoDEBARbIES
    codeforces
    bobebobbes
    b
    TheBBlackbboard

    输出#1

    ity
    YetnotherrokenKeoard
    le
    Imprle
    revile
    
    usyasaeeinaedofloominglossoms
    CDARIES
    codeforces
    es
    
    helaoard

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

首页