#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100005;
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=1;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;
}
算法之路二:刘汝佳算法竞赛入门经典:链表 悲剧文本UVa11988
最新推荐文章于 2020-07-02 17:06:38 发布