http://acm.hdu.edu.cn/showproblem.php?pid=1022

 #include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stack>
using namespace std;
const int N=; int main()
{
//freopen("in.txt","r",stdin);
stack<char>s;
int n,result[N];
char s1[N],s2[N];
int i,j,k;
while(cin>>n>>s1>>s2)
{
i=;j=;k=;
s.push(s1[i]);
result[]=;
while(i<n&&j<n)
{
if(s.size() && s.top()==s2[j])//如果栈取元素和s2当前元素相同,弹栈
{
j++;
s.pop();
result[k++]=;
}
else//如果不相同,继续讲s1后一个元素压栈
{
if(i==n)
break;
s.push(s1[++i]);
result[k++]=;
}
}
if(i==n)//如果i==n代表找不到s2中的当前元素
cout<<"No."<<endl;
else
{
cout<<"Yes."<<endl;
for(i=;i<k;i++)
{
if(result[i])
cout<<"in"<<endl;
else
cout<<"out"<<endl;
}
}
cout<<"FINISH"<<endl;
}
return ;
}

hdu1022 Train Problem I的更多相关文章

  1. HDU1022 Train Problem I 栈的模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 栈的模拟,题目大意是已知元素次序, 判断出栈次序是否合理. 需要考虑到各种情况, 分类处理. 常 ...

  2. hdu1022 Train Problem I---模拟栈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 题目大意: 车的进出站问题,先给出N个火车,再按序列一的方式进站,判断能否以序列二的方式出站,若 ...

  3. (stack)Train Problem I hdu1022

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  5. HDU 1022 Train Problem I

    A - Train Problem I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  6. 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) ...

  7. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  8. sicily 1022. Train Problem

    本题主要是出栈入栈顺序的问题 Home Problems My Status Standing <->           1022. Train Problem     Total: 2 ...

  9. Train Problem I(栈)

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

随机推荐

  1. web前端学习之HTML CSS/javascript之一

    前端编码之路之坎坷,web前端应该一直是个战场吧,各种浏览器的不兼容,各种小细节的修改,要往一个好的产品经理方向走,实在是难,昨天听了一位十年经验的产品经理讲座,最重要的恐怕就是协调资源的能力,而协调 ...

  2. yum被锁定

    使用Yum的时候 提示yum被搜定了 . Another app is currently holding the yum lock; waiting for it to exit...   解决办法 ...

  3. jquery文字上下滚动的实现方法

    jquery实现文字上下滚动的方法. 代码: //上下滚动var textRoll=function(){$('#notice p:last').css({'height':'0px','opacit ...

  4. 跟着PHP100第一季学写一个CMS(11-20)

    PS.刚发现IE并不兼容,有点悲剧  cms1.1密码处理 1.小知识:sha1($_answer) //加密为40位,不知道能不能破解 2.小知识:mysql_real_escape_string( ...

  5. opencv学习笔记(04)——ROI

    ROI的用法:1.直接相加:2.掩码法 #include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgpro ...

  6. sql 对一张表进行按照不同条件进行多次统计

    最近一直在做数据统计,在此过程中,遇到过好多种情况都是对一张表按照不同的条件进行多次统计,以前的做法是统计几次按照不同的条件left join 几次,虽然也能得到想要的结果,但是效率太低,反映在页面就 ...

  7. 【Node.app】Node.js for iOS

    Node.app 是用于 iOS 开发的 Node.js 解释器,它允许最大的代码重用和快速创新,占用资源很少,为您的移动应用程序提供 Node.js 兼容的 JavaScript API.你的客户甚 ...

  8. jQuery 单选按钮切换

    html代码片段一: <div class="row"> <div class="col-sm-12"> <label for=& ...

  9. .NET中 MEF应用于IOC

    IOC解释 IOC,控制反转的意思.所谓依赖,从程序的角度看,就是比如A要调用B的方法,那么A就依赖于B,反正A要用到B,则A依赖于B.所谓反转,你必须理解如果不反转,会怎么着,因为A必须要有B,才可 ...

  10. Palindrome Partitioning

    Palindrome Partitioning Given a string s, partition s such that every substring of the partition is ...