hdu 1022 Train Problem I(栈)
- #include<iostream>
- #include<vector>
- #include<cstring>
- #include<string>
- #include<stack>
- #include<map>
- using namespace std;
- ];
- /*
- 栈的应用
- 若in[i]==out[j]则先进栈后立即出栈,此时只需i++,j++;
- 若in[i]!=out[j]检查栈首是否为out[j],若是,则出栈,并j++,否则将in[i]入栈,并j++
- i==n时,若栈不为空则说明任有火车未出栈,检查栈内元素==out[j++] f[i]: 1表示进栈,0表示出栈
- 。。。。期末考试时不会做,遂记之
- */
- int main()
- {
- freopen("d:\\in.txt", "r", stdin);
- freopen("d:\\out.txt", "w", stdout);
- string in, out;
- int n;
- while(cin>>n)
- {
- ;
- cin>>in>>out;
- bool flag=true;
- , j=;
- stack<char>s;
- while(i<n) {
- if(in[i]==out[j]){
- i++; j++;
- f[cur++]=;
- f[cur++]=;
- }else if(!s.empty()){
- char first=s.top();
- if(first==out[j]){
- j++;
- s.pop();
- f[cur++]=;
- }else{
- s.push(in[i++]);
- f[cur++]=;
- }
- }else {
- s.push(in[i++]);
- f[cur++]=;
- }
- }
- while(!s.empty()){
- char first=s.top();
- f[cur++]=;
- s.pop();
- if(first != out[j++]){
- flag=false;
- break;
- }
- }
- if(flag){
- cout<<"Yes."<<endl;
- ; i<cur; i++){
- )cout<<"in"<<endl;
- else cout<<"out"<<endl;
- }
- cout<<"FINISH"<<endl;
- } else {
- cout<<"No.\nFINISH"<<endl;
- }
- }
- ;
- }
hdu 1022 Train Problem I(栈)的更多相关文章
- Hdu 1022 Train Problem I 栈
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- HDU 1022 Train Problem I(栈的操作规则)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...
- hdu 1022 Train Problem I【模拟出入栈】
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1022.Train Problem I【栈的应用】【8月19】
Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very busy n ...
- HDU - 1022 Train Problem I STL 压栈
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1022 Train Problem I(栈的应用+STL)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1022:Train Problem I(数据结构,栈,递归,dfs)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1022 Train Problem I[给出两个长n的串,入栈和出栈顺序,判断入栈顺序是否可以匹配出栈顺序]
Train Problem I 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 As the new term comes, the Ignatius Train Sta ...
- HDU 1022 Train Problem I
A - Train Problem I Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- hdu 1022 Train Problem
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
随机推荐
- DuiLib 中滚动条不显示的问题
DuiLib 很好用,同时在没有完全理解源码的前提下,坑也不少,比如今天遇到的添加滚动条不显示... 情况是这样的,将一个页面作为Tab控件的其中一页,为了代码不窝在一起,就没有在CreateCont ...
- 使用ab对站点进行压力测试
测试指令: window下: E:\wamp\bin\apache\Apache2.2.21\bin> .\ab -V //查看是否按照了ab:(V 大写) E:\wamp\bin\apach ...
- 能量项链AC了
我打算写出一个尽量看起来像是人话的解题报告. 然而这道题我还是[虽然AC但不会做] OYZ
- c# 操作xml之xmlReader
xmlReader的名称空间using System.Xml; xmlReader是通过流的方式来读取xml文件的内容 <?xml version="1.0" encodin ...
- gulp插件大全
原文:http://www.mamicode.com/info-detail-517085.html No.1.run-sequence 作用:让gulp任务,可以相互独立,解除任务间的依赖,增强 ...
- ligerUI实现分页
在公司实习看到公司框架里使用了ligerUI的grid进行分页,个人感觉挺好用的,自己摸索着实现了一遍记录下来 简单来说,liger grid 就是提交准备好的数据到指定的目标请求数据,拿到数据以后, ...
- UltraEdit-32文本编辑器软件 23.20.0.28 中文版
软件名称: UltraEdit-32文本编辑器软件软件语言: 简体中文授权方式: 共享软件运行环境: Win 32位/64位软件大小: 21.5MB图片预览: 软件简介:UltraEdit 是一个功能 ...
- HTTP状态码(HTTPStatusCode)
HTTP状态码(HTTPStatusCode) 祓焘铺 布稍酡 盛坭馆 距熏屿砥 女装出来扔了套到床上然后自己穿了套 跎徨鼻卩 权术埭 悌颞 蔹咽诹ㄒ 椿酣漂作 钱是小事关键是没有老师耸了 ...
- Hive 常用函数
参考地址:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF 1. parse_url(url, partToExt ...
- dpkg -P <pkg>
http://www.linuxquestions.org/questions/debian-26/how-do-i-get-rid-of-those-rc-packages-as-seen-in-d ...