显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<stack>
using namespace std;
stack<char>sa;
stack<char>que;
string Ans="",P="";
int rebegin,num;
char p='-';
char c[20005],s[20005];
void rejudge(){
for(int i=0;i<strlen(c);i++){
if(c[i]!=']') sa.push(c[i]);
else{
string po="";
char yu; int temp=0;
while(true){
yu=sa.top();sa.pop();
while(yu>='0'&&yu<='9') {
que.push(yu);yu=sa.top();sa.pop();
}
temp=0;
while(!que.empty()){
temp=temp*10+que.top()-48; que.pop();
}
if(yu=='[') break;
po=yu+po;
}
Ans="";
for(int j=1;j<=temp;++j) Ans=Ans+po;
for(int j=0;j<Ans.length();++j) sa.push(Ans[j]);
}
}
while(!sa.empty()){
P=sa.top()+P; sa.pop();
}
}
int main(){
freopen("passworda.in","r",stdin);
freopen("passworda.out","w",stdout);
scanf("%s",c);
rejudge();
cout<<P;
return 0;
}