题目分析:

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

下边附上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. LeetCode28 Implement strStr()

    题目: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if ne ...

  2. Spring mvc编码配置

    Spring3 MVC也带有自己的编码: jar包:org.springframework.web-3.0.0.RELEASE.jar 只需要在web.xml配置即可: <!-- spring ...

  3. Timed Code

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=&qu ...

  4. 【Linux/Ubuntu学习 12】ubuntu下对/etc/profile误修改导致系统不能登录

    etc/profile里设置环境变量导致无法登录解决   1,因为不小心在 etc/profile里设在环境变量导致无法登录    不要在 etc/profile里设置 export PATH这样会导 ...

  5. (搬运)《算法导论》习题解答 Chapter 22.1-1(入度和出度)

    (搬运)<算法导论>习题解答 Chapter 22.1-1(入度和出度) 思路:遍历邻接列表即可; 伪代码: for u 属于 Vertex for v属于 Adj[u] outdegre ...

  6. input[type='submit']input[type='button']button等按钮在低版本的IE下面,去掉黑色边框的问题

    今天做一个tabs效果的时候,发现上面的button在低版本下会出现黑色的边框,很难看,于是我整理了下几个去掉黑色边框的办法: 1.在button的外层嵌套一个div,设置button的border: ...

  7. ionic 中使用ion-slide-box

    ion-slide-box 用法: <ion-slide-box class="slide" auto-play="true" does-continue ...

  8. POJ 1751 Highways (最小生成树)

    Highways Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Sta ...

  9. poj 1947 树形dp

    思路:dp[i][j]表示,以i节点为根,删去j个节点最少要断几条边. 那么dp[u][j]=min(dp[u][j],dp[v][k]+dp[u][j-k]);//选取最优状态 dp[u][j]=m ...

  10. ORACLE之表

    本文章中的表在以后的例子中会用到. 首先有t_fn_person和t_fn_dept表. ) primary key not null, person_code ) not null, person_ ...