UVa 11988

来源:互联网 发布:伤心歌曲500首网络歌曲 编辑:程序博客网 时间:2024/04/30 16:02

#include<stdio.h>
#include<string.h>
int nx[100010];char c[100010];
int main(){
 int i,n,lst,g;
 while(scanf("%s",c+1)!=EOF){
  n=strlen(c+1);
  nx[0]=lst=g=0;
  for(i=1;i<=n;i++)
   if(c[i]=='[')g=0;
   else if(c[i]==']')g=lst;
   else{
    nx[i]=nx[g];
    nx[g]=i;
    if(g==lst)lst=i;
    g=i;
  }for(i=nx[0];i;i=nx[i])
   printf("%c",c[i]);
  puts("");
 }return 0;
}
0 0