当前位置: 代码迷 >> 综合 >> Broken Keyboard (a.k.a. Beiju Text) UVA - 11988
  详细解决方案

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

热度:90   发布时间:2023-10-13 14:34:57.0

问题类型:STL-List

03pie’s solution for [UVA-11988]:
问题链接

#include<cstdio>
#include<cstring>const int maxn=1000000+5;
int last,cur,next[maxn];
char s[maxn];int main(){while(scanf("%s",s+1)==1){int n=strlen(s+1);last=cur=0;next[0]=0;for(int i=0;i<=n;i++){char ch=s[i];if(ch=='[') cur=0;else if(ch==']') 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;
}
  相关解决方案