比赛 清明时节雨纷纷,今天天气很晴朗 评测结果 AAAAAAAAAA
题目名称 外星密码 最终得分 100
用户昵称 TARDIS 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2017-04-06 19:51:06
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#include<deque>
#define itn int
#define coder goodboy
using namespace std;
typedef long long LL;typedef unsigned long long ULL;
char s[20010];int len;
stack<char> a,b,ans;
stack<int> c;
inline void in(){
	freopen("passworda.in","r",stdin);
	freopen("passworda.out","w",stdout);
	scanf("%s",s);
	len=strlen(s);
}
inline void work(){
	for (int i=0;i<len;i++){
		if (isdigit(s[i])){
			int temp=0;
			while (isdigit(s[i])){
				temp*=10;temp+=s[i]-'0';
				i++;
			}
			c.push(temp);
		}
		if (s[i]!=']'){
			b.push(s[i]);
		}
		else {
			string temp1,temp2;
			char temp3=b.top();b.pop();
			while (temp3!='['){
				temp1+=temp3;
				temp3=b.top();b.pop();
			}
			int temp4=c.top();c.pop();
			while (temp4--){
				temp2+=temp1;
			}
			for (int i=temp2.size()-1;i>=0;i--){
				b.push(temp2[i]);
			}
			
		}
	}
}
inline void p(){
	while (!b.empty()){
		ans.push(b.top());b.pop();
	}
	while (!ans.empty()){
		printf("%c",ans.top());ans.pop();
	}
}
int Main(){
	in();
	work();
	p();
	return 0;
}
int main(){;}
int goodboy=Main();