题目分析:

起初这道题目没有做出来,原因是我一直想把整块区域一并插入,而不是逐个插入。今后做题应该注意这个问题,把问题分解去考虑,也许会少走许多弯路。

下边附上AC代码

#include <cstdio>
#include <cstring>
#include <cctype>
char s[100000 + 10];
int next[100000 + 10];
int main(){
    while(scanf("%s", s + 1) == 1){
        int len=strlen(s+1);
        int cur = 0,last=0;
        next[0] = 0;
        for(int i = 1;i <= len;i++){
            if(s[i] =='['){
                cur=0;
            }
            else if(s[i] ==']'){
                cur=last;
            }
            else {
                next[i]=next[cur];
                next[cur]=i;
                if(cur == last)last = i;
                cur=i;
            }
        }
        for(int i = next[0];i != 0;i = next[i]){
            printf("%c",s[i]);
        }
        printf("\n");

}
    return 0;
}
//

例题6-4 Broken Keyboard UVa11988的更多相关文章

  1. UVa 11998 Broken Keyboard (数组模拟链表问题)

    题目链接: 传送门 Broken Keyboard #include<bits/stdc++.h> using namespace std; char str[100010]; int m ...

  2. UVa 11988 Broken Keyboard(链表->数组实现)

    /*数组形式描述链表:链表不一定要用指针. 题目链接:UVa 11988 Broken Keyboard 题目大意: 小明没有开屏幕输入一个字符串,电脑键盘出现了问题会不定时的录入 home end ...

  3. 1084. Broken Keyboard (20)

    On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...

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

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

  6. PAT1084:Broken Keyboard

    1084. Broken Keyboard (20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a ...

  7. PAT 1084 Broken Keyboard

    1084 Broken Keyboard (20 分)   On a broken keyboard, some of the keys are worn out. So when you type ...

  8. A1084. Broken Keyboard

    On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters ...

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

随机推荐

  1. C. Ilya and Sticks

    C. Ilya and Sticks time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. Android Studio常用快捷键汇总(mac)

    查看原文:http://blog.csdn.net/u010818425/article/details/52266195 mac上按键符号 ⌥ : option / alt ⇧ : shift ⌃ ...

  3. 重构17-Extract Superclass(提取父类)

    当一个类有很多方法希望将它们“提拔”到基类以供同层次的其他类使用时,会经常使用该重构.下面的类包含两个方法,我们希望提取这两个方法并允许其他类使用. public class Dog { public ...

  4. ASP.NET MVC ViewData/ViewBag 简单小结

    近期在项目中遇到一个问题,就是用ViewBag.Model存储匿名对象传递给View,但是需要根据条件给匿名对象添加属性,这个可真心不易,Google了一下发现很多方案都是动态编译神马的,感觉好高大上 ...

  5. 剑指Offer14 逆序链表

    /************************************************************************* > File Name: 14_Revers ...

  6. jQuery.Hotkeys - lets you watch for keyboard events anywhere in your code supporting almost any key combination

    About jQuery Hotkeys is a plug-in that lets you easily add and remove handlers for keyboard events a ...

  7. Part 3 ViewData and ViewBag in mvc

    ViewBag and ViewData is a mechanism(机制) to pass data from controller to view. We use '@' symbol(符号) ...

  8. SQL中char、varchar、nvarchar

    char    char是定长的,也就是当你输入的字符小于你指定的数目时,char(8),你输入的字符小于8时,它会再后面补空值.当你输入的字符大于指定的数时,它会截取超出的字符.   nvarcha ...

  9. 可以伸缩的查询面板 (searchBar)

    最近有这样的需求,一个页面查询条件特别多,一次全部展示出来的话就占用大量的空间,所以分成了两类,简单搜索和高级搜索,当点击高级搜索的时候就会全部显示. 这样就存在一个问题,页面(navTab,dial ...

  10. JSP之邮箱检验

    首先创建Email类继承Serializable接口以启用其序列化功能,而序列化又是为了保持版本的兼容性,即在版本升级时反序列化仍保持对象的唯一性.序列化接口没有方法或字段,仅用于标识可序列化的语义. ...