比赛 20241022 评测结果 AAAAAAAAAA
题目名称 解压缩 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.037 s
代码语言 C++ 内存使用 3.41 MiB
提交时间 2024-10-22 08:46:36
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define in inline
#define se second
#define mp make_pair
#define pb push_back
const int N = 1e5+10;

ll read(){
	ll x = 0,f = 1;char c = getchar();
	for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
	for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
	return x * f;
}


int n;
char c[510];

void work(int l,int r){
	for(int i = l;i <= r;i++){
		if(c[i] == '['){
			int j = i+1,x = 0,s = 1;
			for(;j <= r;j++)
				if('0' <= c[j] && c[j] <= '9')x = x * 10 + c[j] - '0';
				else break;
			int nx = j;
			for(;nx <= r;nx++){
				if(c[nx] == '[')s++;
				else if(c[nx] == ']')s--;
				if(!s)break;
			}
			for(int cnt = 1;cnt <= x;cnt++)work(j,nx-1);
			i = nx;
		}
		else if('A' <= c[i] && c[i] <= 'Z')cout<<c[i];
	}
}
int main(){
	freopen("extract.in","r",stdin);
	freopen("extract.out","w",stdout);
	scanf("%s",c + 1);
	n = strlen(c + 1);
	work(1,n);

	return 0;

}