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

题意:给出火车的进站与出站顺序,判断是否可以按照给出的出站顺序出站。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <math.h> using namespace std; #define INF 0x3f3f3f3f
const int maxn = ;
typedef long long LL; int main()
{
int n;
int a[];
char str1[], str2[]; while(scanf("%d%s%s", &n, str1, str2)!=EOF)
{
stack<char>Q;
Q.push(str1[]); memset(a, , sizeof(a));
a[] = ; int i=;
int j=;
int k=; while(i<n && j<n)
{
if(Q.size() && Q.top()==str2[j])
{
a[++k]=;
Q.pop();
j++;
}
else
{
Q.push(str1[++i]);
a[++k]=;
}
} if(k!=*n) printf("No.\n");
else
{
printf("Yes.\n"); for(int i=;i<=k;i++)
if(a[i])
printf("in\n");
else
printf("out\n"); }
printf("FINISH\n");
}
return ;
}

Train Problem I hdu 1022(栈)的更多相关文章

  1. HDU - 1022 Train Problem I STL 压栈

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

  2. Train Problem II HDU 1023 卡特兰数

    Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...

  3. HDU 1022 Train Problem I (数据结构 —— 栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  4. HDU Train Problem I (STL_栈)

    Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...

  5. Train Problem I (HDU 100题纪念)

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  6. Train Problem I(模拟栈)

    题意:模拟栈,试问使用2个栈,能否使得串1变为串2 思路:模拟,经典问题,注意只要相同的元素放到栈顶后就不会再移动了,只需要考虑剩下的元素,因此每次只考虑一个元素的进入方式. #include< ...

  7. HDU 1022 Train Problem I(栈的操作规则)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...

  8. hdu 1022 Train Problem I【模拟出入栈】

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

  9. Hdu 1022 Train Problem I 栈

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

随机推荐

  1. 【C】 03 - 数据类型

    程序说到底就是对数据的处理,所以首先要弄清楚需要处理哪些数据,计算机如何存储这些数据.C语言根据需要,抽象出了一些基本数据类型和衍生数据类型.这些可以满足大部分需求,更复杂的抽象数据类型亦可通过它们来 ...

  2. ulipad python配置

    运行                                                                                   打开程序之后,界面非常友好,创 ...

  3. DevExpress中GridView上的右键菜单

    1. 先拖一个PopupMenu和BarManage控件,设置PopupMenu的Manager属性为BarManager. 2. 先选中GridView,不是GridControl,在属性窗口中,选 ...

  4. StringIO学习

    StringIO StringIO的行为与file对象非常像,但它不是磁盘上文件,而是一个内存里的“文件”,我们可以将操作磁盘文件那样来操作StringIO.一个简单的例子,让你对StringIO有一 ...

  5. 黑马程序员_ JAVA中的多线程

    ------- android培训.java培训.期待与您交流! ---------- 尽管线程对象的常用方法可以通过API文档来了解,但是有很多方法仅仅从API说明是无法详细了解的. 本来打算用一节 ...

  6. 用自己的ID在appstore中更新app-黑苹果之路

    由于之前套用了别人的镜像,在appstore中更新XCode时总要输别人id的密码,id还不能改.网上有的说要把XCode删掉,然后再用自己的ID更新,找到另外一个方法,更简单: 1.打开引用程序目录 ...

  7. RealtekRTL8111内建网卡-黑苹果之路

    真是服了这神一样的黑苹果.好不容易配好显卡,登陆appstore却报“无法验证您的设备或电脑”,查了一圈,又说要配网卡为en0的,有说要在clover中配FIXLAN的,最准确的是网卡必须是内建(Bu ...

  8. HDU2045

    http://acm.hdu.edu.cn/showproblem.php?pid=2045 如果n-1的颜色和1相同,那么n有两种走法,如果n-1 的颜色和1不同,那么n只有1种选择方法 公式就是f ...

  9. loadrunner11遇到的问题汇总及相应的解决方案(持续更新)

    1.在此界面点击Run Load Tests提示: "Can not save the license information because access to the registry  ...

  10. bash检查文件格式

    情形描述:最近在做一个ETL的项目,用的是CLoverETL,需要在拿到文件后对文件格式进行检验,以决定是否继续. 主要功能是检查每个文件中有几个“|”符号,项目中约定以该符号来作为分隔,所以检查每个 ...