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. Linux故障-bash-4.1$

    #模拟故障:-bash-4.1$ [root@nodchen ~]# su - cisco[cisco@nodchen ~]$ \rm -f .*rm: cannot remove `.': Is a ...

  2. Linux常用的一些基础命令

    删除 rm -rvf * -f:强制删除文件或文件夹 -r:递归的删除文件或文件夹 -i:删除文件或文件夹前需要确认 -v:详细显示进行步骤 查看 ls ll        ls -l cat mor ...

  3. 阿里云内网和公网NTP服务器和其他互联网基础服务时间同步服务器

    阿里云为云服务器ECS提供了内网NTP服务器,对于阿里云以外的设备,阿里云同时提供了 公网NTP服务器,供互联网上的设备使用. 内网和公网NTP服务器 以下为阿里云提供的内网和公网NTP服务器列表. ...

  4. Mybatis -代码自动生成(generatorConfig.xml)

    参考:http://blog.csdn.net/jinshiyill/article/details/51546676 官方网址: http://www.mybatis.org/generator/c ...

  5. javascript面向对象之Object.defineProperty(a,b,c)

    /* Object.defineProperty(a,b,c);介绍 a:需要属性设置的对象 b:需要设置的属性名,(键值) c:是一个用于描述属性值得json数据.这个json数据有configur ...

  6. MySQL ALTER讲解

    当我们需要修改数据表名或者修改数据表字段时,就需要使用到MySQL ALTER命令. 开始本章教程前让我们先创建一张表,表名为:testalter_tbl. root@host# mysql -u r ...

  7. Select算法(最坏复杂度O(n))

    #include<iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm&g ...

  8. Dep数据发布,推送

    package com.cfets.ts.u.shchgateway.util; import com.cfets.cwap.s.stp.MessageUnit; import com.cfets.t ...

  9. 2018-2019-2 《网络对抗技术》Exp3 免杀原理与实践 Week5 20165233

    Exp3 免杀原理与实践 实验内容 一.基础问题回答 1.杀软是如何检测出恶意代码的? 基于特征码的检测:通过与自己软件中病毒的特征库比对来检测的. 启发式的软件检测:就是根据些片面特征去推断.通常是 ...

  10. Javascript,获取元素,write方法

    一:Javascript:弱类型脚本语言,是一种动态类型.实现部分动画效果和用户交互等 -- html是骨架(页面结构)  css样式  js是行为 -- 弱类型体现: JS代码可以写在body,he ...