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).

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

HINT

字符'['将链表指针置于头,字符’]‘将链表指针置于尾部。插入字符用insert(pos,var);第一个参数是一个指针,指向要插入的地址前面,后面的是要插入的值。返回插入的地址。

Accepted

#include<bits/stdc++.h>
using namespace std; int main(){
string s;
while (getline(cin, s) && s.length()) {
list<char>L;
auto p = L.begin();
for (int i = 0;i < s.length();i++) {
if (s[i] == '[')p = L.begin();
else if (s[i] == ']')p = L.end();
else {
p=L.insert(p, s[i]);
p++;
}
}
for (p = L.begin();p != L.end();p++)cout << *p;
cout << endl;
}
}

Broken Keyboard (a.k.a. Beiju Text) UVA - 11988的更多相关文章

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

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

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

    题目链接:https://vjudge.net/problem/UVA-11988 题目大意:输入一个字符串,输出在原本应该是怎么样的?  具体方法是 碰到' [ ' 回到最前面  碰到‘ ]’  回 ...

  3. 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 ...

  4. 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 ...

  5. B - 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 ...

  6. N - Broken Keyboard (a.k.a. Beiju Text)(DFS,链表)

    N - Broken Keyboard (a.k.a. Beiju Text) Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:% ...

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

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

  8. UVa 11988 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 wi ...

  9. 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 ...

随机推荐

  1. js如何判断一假则假,全真则真

    思路:初始化flag参数为true,一旦有一个为假,则将flag赋值为false,最后返回. 代码如下: checkSupplyWt(list){ var flag = true; list.forE ...

  2. 使用dlopen加载动态库

    目录 概述 接口 C CMakeLists.txt src/main.c src/add.c ./dlopen_test C++ CMakeLists.txt src/main.cpp src/add ...

  3. dubbo-zookeeper quick start

    目录 dubbo快速开始 服务提供者(Service provider) 定义服务接口(Defining service interfaces) 在服务提供方实现接口(Implement interf ...

  4. javascript处理HTML的Encode(转码)和解码(Decode)

    HTML的Encode(转码)和解码(Decode)在平时的开发中也是经常要处理的,在这里总结了使用javascript处理HTML的Encode(转码)和解码(Decode)的常用方式 一.用浏览器 ...

  5. 【转载】markdown数学常用公式箭头符号

    来源1:https://www.jianshu.com/p/3f01c5658356 来源2:https://blog.csdn.net/smstong/article/details/4434063 ...

  6. C#使用OpenCV剪切图像中的圆形和矩形

    前言 本文主要介绍如何使用OpenCV剪切图像中的圆形和矩形. 准备工作 首先创建一个Wpf项目--WpfOpenCV,这里版本使用Framework4.7.2. 然后使用Nuget搜索[Emgu.C ...

  7. CVE-2016-10033 WordPress <= 4.6 命令执行漏洞

    漏洞参考 https://www.jianshu.com/p/85ac4af9f947 漏洞信息 这个锅还是要PHPMailer背(CVE-2016-10033,WordPress 使用 PHPMai ...

  8. Shtml、html、xhtml、htm以及SSI的了解与认识(转载)

    Shtml.html.xhtml.htm以及SSI的了解与认识(转载) 一.htm.html.shtml网页区别(博客园) 文章链接:https://www.cnblogs.com/Renyi-Fan ...

  9. linuxc语言图形化编程包含gtk/gtk.h编译总是报错找不到该文件的解决方法

    在编译时输入gcc file.c `pkg-config --libs --cflags gtk+-2.0` 注意`不是单引号,和--前均有一个字符 这样问题就结局啦

  10. 关于java的访问修饰符权限

    作用域    public protected default private  同一个类   yes     yes      yes      yes 同一个包   yes     yes    ...