UVa11988:Broken Keyboard

Description

                                Broken Keyboard
You‘re typing a long text with a broken keyboard. Well it‘s not so badly broken. The only problem with the keyboard is that sometimes the "home" key gets automatically pressed (internally).

You‘re not aware of this issue, since you‘re focusing on the text and did not even turn on the monitor! After you finished typing, you can see a text on the screen (if you turn on the monitor).

In Chinese, we can call it Beiju. Your task is to find the Beiju text.

Input

There are several test cases. Each test case is a single line containing at least and at most 100,000 letters, underscores and two special characters ‘[‘ and ‘]‘. ‘[‘ means the ‘Home‘ key is pressed internally, and ‘]‘ means the ‘End‘ key is pressed internally. The input is terminated by end-of-file (EOF). The size of input file does not exceed 5MB.

Output

For each case, print the Beiju text on the screen.

Sample Input

This_is_a_[Beiju]_text
[[]][][]Happy_Birthday_to_Tsinghua_University

Output for the Sample Input

BeijuThis_is_a__text
Happy_Birthday_to_Tsinghua_University

-----------------------------------------------------------------------------------------------------

思路解析:

时间: 2024-10-12 22:25:13

UVa11988:Broken Keyboard的相关文章

UVa11988 Broken Keyboard(悲剧文本)

UVa11988 Broken Keyboard(悲剧文本) 题目链接:UVa11988 题目描述: 输入包含多组数据,每组数据占一行,包含不超过100000个字母.下划线.字符"["或者"]".其中字符"["表示Home键,"]"表示End键.输入结束标志为文件结束符(EOF)输入文件不超过5MB,对于每组数据,输出一行,即屏幕上的悲剧文本 样例输入: This_is_a_[Beiju]_text [[]][]Happy_B

UVA11988 Broken Keyboard (a.k.a. Beiju Text)【数组模拟链表】

Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automatically pressed (inter

Uva11988 Broken Keyboard (a.k.a. Beiju Text)(就是先输出括号的字符)

Description Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets automa

UVA11988 Broken Keyboard (a.k.a. Beiju Text)

看到大一练习题,睡前水一水~~~ Problem B Broken Keyboard (a.k.a. Beiju Text) You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problem with the keyboard is that sometimes the "home" key or the "end" key gets a

UVA-11988 Broken Keyboard (a.k.a. Beiju Text) (链表 或 递归)

题目大意:将一个字符串改变顺序后输出.遇到“[”就将后面内容拿到最前面输出,遇到“]”就将后面的内容拿到最后面输出. 题目分析:用nxt[i]数组表示i后面的字符的下标,实际上就是以字符i为头建立链表,写法类似链式前向星. 代码如下: # include<iostream> # include<cstdio> # include<cstring> # include<algorithm> using namespace std; char p[100005]

UVA11988 Broken Keyboard 链表

题目描述: 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. 给你一段按键的文本,其中'['表示Home键,']'表示End键,输出这段悲剧的文本. 解题思路 用顺序结构储存会超时 所以用模拟链表来储存 cur表示光标的位置 last表示当前最后一个字符的编号 next[i]表示s[i]后面的字符的编号 为了方便起见在数组的最前面虚拟一个s[0].代码如下 #include <cstdio> #include <cstring> #include <

UVa11988 Broken Keyboard (a.k.a. Beiju Text) (链表)

链接:http://acm.hust.edu.cn/vjudge/problem/18693分析:链表.用nxt[i]保存s[i]右边字符在s中的下标.增加一个虚拟字符s[0],那么nxt[0]就是显示屏中最左边的字符.cur表示光标位置左边的字符在s数组中的下标,last表示显示屏中最后一个字符在s数组中的下标.其实就是用nxt链表重新组织s数组的输出顺序,输入一个字符,先将新插入字符的nxt[i]指向nxt[cur],再将nxt[cur]指向i,就是在链表元素cur后插入元素i,更新最后一个

【日常学习】【非指针链表】Uva11988 - Broken Keyboard (a.k.a. Beiju Text)题解

这道题目拖了好几天,因为鄙人有两大天敌--链表和树TUT看了这个题材知道原来链表可以不用指针写,不过原理也是一样的,相当于是用数组模拟了个链表而不实用结构体,结构体里的指针就换成了两个变量cur和last了.这道题目本来测出来非常奇怪和合因为UVA AC HDU TLE SPOJ RE我正在奇怪,才发现同名的不同题目有三道TUT 题目的详解已经写在了注释里,上代码: #include<cstdio> #include<cstring> using namespace std; co

UVa11988 Broken Keyboard(练习链表使用)

向量和数组的优势是可以随机的存取元素和在末尾添加删除元素,而当插入元素时,需要移动大量的数据,消耗大量的时间.而链表的优势是可以在O(1)删除和插入数据.所以在频繁移动元素时,可以使用链表. 分析:如果用一个数组来保存,题目中的文本随着光标位置的移动需不断的插入字符,这样会导致大量字符移动问题.解决方案是采用链表,将字符串保存在buf[1...n]中,然后用next[i]表示下标为i的字符的下一个位置的下标(链表不一定用指针实现).为了方便起见,用一个虚拟的next[0]指向显示屏最右边的字符下