比赛 |
20121030 |
评测结果 |
AAAAAAAAAA |
题目名称 |
外星密码 |
最终得分 |
100 |
用户昵称 |
QhelDIV |
运行时间 |
0.005 s |
代码语言 |
C++ |
内存使用 |
3.51 MiB |
提交时间 |
2012-10-30 21:03:55 |
显示代码纯文本
- #include <fstream>
- #include <algorithm>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- ifstream fin("passworda.in");
- ofstream fout("passworda.out");
- string S,Ans;
- int top=0,pos=0;
- class STACK
- {
- public:
- int V,Multiple;
- string R;
- }stack[20001];
- void Initialize()
- {
- fin>>S;
- S.insert(0,"[1");
- S.push_back(']');
- }
-
- string DFS()
- {
- int Ti;
- string Q="\0";
- pos++;
- if('0'<=S[pos+1] && S[pos+1]<='9')
- Ti=(S[pos]-'0')*10+S[pos+1]-'0',pos+=2;
- else
- Ti=S[pos]-'0',pos++;
- while(S[pos]!=']')
- {
- while(S[pos]=='[')
- Q+=DFS();
- if(S[pos]==']')
- break;
- Q.push_back(S[pos]);
- pos++;
- }
- string P=Q;
- for(int i=2;i<=Ti;i++)
- Q+=P;
- pos++;
- return Q;
- }
-
- int main()
- {
- Initialize();
-
- fout<<DFS()<<endl;
-
- fin.close();
- fout.close();
- return 0;
- }