UVa 11988 broken Keyboard (array analog list)

Source: Internet
Author: User

Topic Links:

https://cn.vjudge.net/problem/UVA-11988

1 /*2 The problem is that a piece of text after a certain rule processing output, the rule is [the home key, indicating that the cursor jumps to the beginning of the line,] means the end key, indicating that the cursor jumps to the end3 4 Thinking of solving problems5 It can be found that [] can be nested, using pure simulation is more complex, similar to the next array in the KMP, record the next character position of each character, and finally6 output can be. 7 */ 8#include <iostream>9#include <cstdio>Ten#include <cstring> One#include <list> A Const intmaxn=101000; - using namespacestd; -  the CharSTR[MAXN]; - intNEX[MAXN]; - intMain () - { +     intI,len,cur,las; -     //freopen ("E:\\testin.txt", "R", stdin); +      while(SCANF ("%s", str+1) !=EOF) { ALen=strlen (str+1); atcur=las=0; -nex[0]=0; -          for(i=1; i<=len;i++){ -             if(Str[i] = ='[') -Cur=0; -             Else if(Str[i] = =']') inCur=Las; -             Else{ tonex[i]=Nex[cur]; +nex[cur]=i; -                 if(cur = = las) Las =i; theCur =i; *             } $         }Panax Notoginseng          -          for(i=nex[0];i! =0; i=Nex[i]) { theprintf"%c", Str[i]); +         } APuts""); the     }     +     return 0; -}

UVa 11988 broken Keyboard (array analog list)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.