| 比赛 |
20251022赛前模拟1 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
解压缩 |
最终得分 |
100 |
| 用户昵称 |
梦那边的美好TE |
运行时间 |
0.026 s |
| 代码语言 |
C++ |
内存使用 |
3.79 MiB |
| 提交时间 |
2025-10-22 09:31:16 |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N=505;
char s[N];
int stk[N],top;
string dfs(int l,int r){
l++;int x=0;string now="",res="";
while(s[l]>='0'&&s[l]<='9')x=x*10+s[l]-'0',l++;
for(int i=l,j;i<r;i=j+1){
if(s[i]!='['){
j=i;
now.push_back(s[i]);
}else{
stk[top=1]='[';
for(int k=i+1;;k++){
if(s[k]=='[')stk[++top]='[';
else if(s[k]==']'){
if(top==1){
j=k;break;
}else{
stk[top--];
}
}
}
now+=dfs(i,j);
}
}
while(x--)res+=now;
return res;
}
int main(){
freopen("extract.in","r",stdin);
freopen("extract.out","w",stdout);
scanf("%s",s+3);
int n=strlen(s+3);n+=2;
s[1]='[',s[2]='1',s[++n]=']';
cout<<dfs(1,n)<<endl;
return 0;
}