UVa 11988 Broken Keyboard (a.k.a. Beiju Text)

Source: Internet
Author: User

Problem copy too troublesome, throw a link

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18693

Direct simulation of the cursor operation time is more complex, so the list is stored in the order.

POS indicates the cursor position

1#include <cstdio>2#include <iostream>3#include <cstring>4#include <algorithm>5#include <cmath>6 using namespacestd;7 Chars[200000];8 Charch;9 intLast,pos;//last store the position of the final character, POS stores the current cursor positionTen intnexto[200000]; One intMain () { A      while(SCANF ("%s", s+1)!=EOF) { -         intLen=strlen (s+1); -last=0;p os=0; thenexto[0]=0;//Initialize -         inti; -          for(i=1; i<=len;i++){ -             if(s[i]=='[') pos=0; +             Else if(s[i]==']') pos=Last ; -             Else{ +nexto[i]=Nexto[pos]; Anexto[pos]=i; at                 if(Pos==last) last=i;//Update last Location -Pos=i;//Update cursor Position -             } -         } -          for(i=nexto[0];i!=0; I=nexto[i]) printf ("%c", S[i]); -printf"\ n"); in     } -     return 0; to}

UVa 11988 Broken Keyboard (a.k.a. Beiju Text)

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.