Train Problem I
问题陈述:
杭州电子科技大学HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1022
问题解析:
栈(stack)的简单应用
代码详解:
#include <iostream>
#include <cstdio>
#include <stack>
#include <cstring> using namespace std; stack<int> s; int flag[]; int main()
{
int n, i, j, k;
char o1[], o2[];
while(~scanf("%d %s%s", &n, o1, o2)){
while(!s.empty()){
s.pop();
}
memset(flag, -, sizeof(flag));
j = k = ;
for(i=; i<n; i++) {
s.push(o1[i]);
flag[k++] = ;
while(!s.empty() && s.top()==o2[j]) {
s.pop();
flag[k++] = ;
j++;
}
}
if(j == n) {
cout << "Yes." <<endl;
for(i=; i<k; i++) {
if(flag[i]) {
cout << "in" <<endl;
}else {
cout << "out" << endl;
}
}
}else {
cout << "No." << endl;
}
cout << "FINISH" << endl;
}
return ;
}
参考博客:http://blog.csdn.net/lyhvoyage/article/details/18505997
转载请注明出处:http://www.cnblogs.com/michaelwong/p/4315668.html
Train Problem I的更多相关文章
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- HDU 1022 Train Problem I
A - Train Problem I Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- Train Problem I 分类: HDU 2015-06-26 11:27 10人阅读 评论(0) 收藏
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1023 Train Problem II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...
- sicily 1022. Train Problem
本题主要是出栈入栈顺序的问题 Home Problems My Status Standing <-> 1022. Train Problem Total: 2 ...
- Train Problem I(栈)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Train Problem I--hdu1022(栈)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Train Problem II(卡特兰数+大数乘除)
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 1023 Train Problem II(卡特兰数)
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
- train problem I (栈水题)
杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/ ...
随机推荐
- centos7.0 php-fpm 安装ImageMagic php扩展imagick
Just copy and paste: $ yum install make $ yum install gcc $ yum install php php-fpm php-devel php-pe ...
- 深入学习微框架Spring-boot
深入学习微框架:Spring Boot 深入学习微框架:Spring Boot
- Bing必应(Yahoo雅虎)搜索引擎登录网站 - Blog透视镜
Bing必应是微软的搜索引擎,原本是置放在MSN网站上的,微软重新开发并改为新的名子,只要连到官网,登录网站后,过了不久,搜索引擎就会用爬虫,来检索你的网站,等过了一阵子之后,自然就可以找到你的文章. ...
- web技术之图片预加载
http://www.cnblogs.com/rt0d/archive/2011/04/17/2018646.html http://www.oschina.net/code/snippet_5437 ...
- mysql 事务控制
#!/usr/bin/perl use DBI; $db_name='zjzc'; $ip='127.0.0.1'; $user="root"; $passwd="123 ...
- 转:LINQ查询返回DataTable类型
动态绑定ReportViewer虽然之前实现过,但现在弄起来还是有点晕,主要是过去没有使用Linq,数据的操作经常用到DataTable,可以直接拿来使用,现在用Linq更方便,也懒得再用之前的数据库 ...
- Minimum Depth of Binary Tree 解答
Question Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along ...
- 《如何让TT T4模板输出多个文件(VS2010中)》-- access911.net 文章
<如何让TT T4模板输出多个文件(VS2010中)>-- access911.net 文章 问题: VS2010中自带的 TT 模板功能挺好用,但是如何定义其输出的目录,或者如何 ...
- error LNK2019
error LNK2019: 无法解析的外部符号 "public: virtual __thiscall Fruit::~Fruit(void)" (??1Fruit@@UAE@X ...
- formidable上传图片
function uploadfiles(res, req){ var form = new formidable.IncomingForm(); form.parse(req,function(er ...