| 比赛 |
20251022赛前模拟1 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
解压缩 |
最终得分 |
100 |
| 用户昵称 |
李奇文 |
运行时间 |
0.029 s |
| 代码语言 |
C++ |
内存使用 |
3.74 MiB |
| 提交时间 |
2025-10-22 11:46:51 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
string s;
int n;
int main(){
freopen("extract.in","r",stdin);
freopen("extract.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>s;
s="[1"+s+"]";
n=s.length();
stack<int> b;
stack<string> ss;
ss.push("");
for(int i=0;i<n;i++){
int sum=0;
if('A'<=s[i]&&s[i]<='Z'){
string t;
while('A'<=s[i]&&s[i]<='Z'){
t=t+s[i];i++;
}
i--;
t=ss.top()+t;
ss.pop();
ss.push(t);
}
if(s[i]=='['){
while('0'<=s[i+1]&&s[i+1]<='9'){
sum=sum*10+s[i+1]-'0';
i++;
}
b.push(sum);
ss.push("");
}
if(s[i]==']'){
int k=b.top();
b.pop();
string h,t;
h=ss.top();
ss.pop();
while(k--){
t+=h;
}
t=ss.top()+t;
ss.pop();
ss.push(t);
}
}
cout<<ss.top();
return 0;
}
//n*m-n-m-k+1;