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 (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 one 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

Sample Output

BeijuThis_is_a__text
Happy_Birthday_to_Tsinghua_University

题意

每次把“[”和"]"里面的东西放到最前面

题解

正常暴力不用考虑,TLE

数组操作的就不说了,这是用链表做的

代码

 #include<bits/stdc++.h>
using namespace std;
struct node
{
char data;
struct node *next;
};
int main()
{
char s[];
while(scanf("%s",s)!=EOF)
{
node *head=(node*)malloc(sizeof(node)),*rear,*p;
head->next=NULL;
p=rear=head;//第一个对头操作
for(int i=;s[i];i++)
{
char ch=s[i];
if(ch=='[')
p=head;
else if(ch==']')
p=rear;
else
{
node *q=(node*)malloc(sizeof(node));
q->data=ch;
q->next=p->next;
p->next=q;
if(p==rear)
rear=q;
p=q;
}
}
p=head->next;
while(p)
{
printf("%c",p->data);
p=p->next;
}
printf("\n");
}
return ;
}

UVa 11988 Broken Keyboard (a.k.a. Beiju Text)(链表)的更多相关文章

  1. UVA——11988 Broken Keyboard (a.k.a. Beiju Text)

    11988 Broken Keyboard (a.k.a. Beiju Text)You’re typing a long text with a broken keyboard. Well it’s ...

  2. UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(链表)

    题目代号:UVA 11988 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&pa ...

  3. 链表 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)

    题目传送门 题意:训练指南P244 分析:链表模拟,维护链表的head和tail指针 #include <bits/stdc++.h> using namespace std; const ...

  4. UVa 11988 Broken Keyboard (a.k.a. Beiju Text)

    题目复制太麻烦了,甩个链接 http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693 直接模拟光标操作时间复杂度较高,所以用链 ...

  5. 暑假集训单切赛第二场 UVA 11988 Broken Keyboard (a.k.a. Beiju Text)(字符串处理)

    一开始不懂啊,什么Home键,什么End键,还以为相当于括号,[]里的东西先打印出来呢.后来果断百度了一下. 悲催啊... 题意:给定一个字符串,内部含有'['和']'光标转移指令,'['代表光标移向 ...

  6. UVa 11988 - Broken Keyboard (a.k.a. Beiju Text) 题解

    刘汝佳的题目,悲剧文本 -_-||| 这里使用vector<string>容器倒置记录数据,然后从后面输出就能够了. 难度就是不知道这种文档究竟哪里是開始输出,故此使用动态管理内存的容器比 ...

  7. UVA 11988 Broken Keyboard (a.k.a. Beiju Text) (链表,模拟)

    使用list来模拟就行了,如果熟悉list,那么这道题真是分分钟秒掉... list是双向循环链表,插入和删除操作非常快,缺点是不能像数组一样随机按下标读取. 一下是wiki上说明的相关函数:http ...

  8. uva - Broken Keyboard (a.k.a. Beiju Text)(链表)

    11988 - Broken Keyboard (a.k.a. Beiju Text) You’re typing a long text with a broken keyboard. Well i ...

  9. 破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988)

    破损的键盘(悲剧文本)(Broken Keyboard(a.k.a. Beiju Text),Uva 11988) 题意描述 你在输入文章的时候,键盘上的Home键和End键出了问题,会不定时的按下. ...

随机推荐

  1. jenkins持续集成3

    1.安装Pipeline插件,并初识 1.启动Jenkins,打开浏览器http://localhost:8080,系统管理,用户名:chenshanju/123456 2.系统管理-插件管理,安装p ...

  2. 3-4 1449 web view

    1.app类型 不同类型的应用 区别 native app 纯原声app,Android用Java些,iOS用object c写 hybrid app 套用原声应用的外壳,既有原生的UI页面,又通过内 ...

  3. mongo获取lbs数据

    进入mongo目录执行./mongo 命令 #切换数据库use coachloc db.runCommand({geoNear : "coachloc" ,near : [113. ...

  4. Java 导入证书

    在这个目录下: ${JAVA_HOME}\jre\lib\security 执行 keytool -importcert -trustcacerts -file yourcerfile.pem -al ...

  5. 学习MongoDB 八: MongoDB索引(索引限制条件)(二)

    一.简介 我们上一篇介绍了索引基本操作,通过db.collection.createIndex(keys, options)语法创建索引,我们继续介绍地理空间索引.索引的限制,使我们在MongoDB时 ...

  6. JavaScript中判断函数、变量是否存在

    转载:http://www.jb51.net/article/67551.htm 一.是否存在指定函数 function isExitsFunction(funcName) { try { if (t ...

  7. faker模块基本用法

    引言: 自动化脚本编写时,一般会遇到需要构造数据的情况,比如注册时的基本信息:每次执行脚本都要重新构造数据显然是很费时费力的事情,所以可以用到faker模块来构造:方便快捷,神器也: 一.安装 pip ...

  8. mysql级联删除

    一个building对应多个rooms,building删除----级联删除相关的rooms 第一步, 创建buildings表,如下创建语句: USE testdb; CREATE TABLE bu ...

  9. laravel5.4中ajax删除数据

    1 JS代码 function deleteInfo(id) { if(id) { var r=confirm('确定要删除吗'); if(r==true) { $.ajax({ url: " ...

  10. CentOS Apache配置详解

    要想在linux上实现网页服务器(www)需要Apache这个服务器软件,不过Apache仅能提供最基本的静态网站数据而已,想要实现动态网站的话,最好还是要PHP与MySQL的支持,所以下面我们将会以 ...