TCL之容器
-
[A] A Breaking Computer
- 时间限制: 1000 ms 内存限制: 65535 K
- 问题描述
-
Oh my god.My computer is break.When I writing something,the home and the end always is working.But I also write too quakily,
even I don't see the screen.OK,when I finish a work ,can you tell me the work become in end?
We modified the sample output, please check it. - 输入
-
This have some cases.
Every case have a sentence(length< 200000 Include (A->Z a->z 0->9)).Then '[' is the home,']' is the end; - 输出
-
Input a sentence.
Printf the finally sentence. - 样例输入
-
123[4 123[45]6 123[45]6[7]8
- 样例输出
-
4123 451236 74512368
代码实现:
#include<iostream> #include<stdio.h> #include<vector> using namespace std; char str[200001]; vector<char>Q[200001];//定义200001个容器 int main() { int i,j,r,flag; while(scanf("%s",str)!=EOF) { r=0;flag=0; for(i=0;i<200001;i++) Q[i].clear();//容器的清空 for(i=0;str[i]!='\0';i++) { if(str[i]=='[') { r++; flag=r; } else if(str[i]==']') flag=0; else { Q[flag].push_back(str[i]);//进入容器 } } for(i=r;i>=0;i--) { for(j=0;j<Q[i].size();j++) printf("%c",Q[i][j]); } printf("\n"); } return 0; }
posted on 2013-03-17 14:45 后端bug开发工程师 阅读(276) 评论(0) 编辑 收藏 举报