这道题是道简单的栈模拟题,只要按照真实情况用栈进行模拟即可:

#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
int main()
{
int n, i, j, k, flag[];
char s1[], s2[];
stack <char> s;
while(~scanf("%d %s%s",&n,s1,s2))
{
while(!s.empty()) s.pop(); //也可以不写这一句,把 stack <char> s; 就可以了
memset(flag,-,sizeof(flag));
j = k = ;
for(i = ; i < n; i++)
{
s.push(s1[i]);
flag[k++] = ;
while(!s.empty() && s.top() == s2[j])
{
flag[k++] = ;
s.pop();
j++;
}
}
if(j == n)
{
printf("Yes.\n");
for(i = ; i < k; i++)
{
if(flag[i])
printf("in\n");
else
printf("out\n");
}
}
else
printf("No.\n");
printf("FINISH\n");
}
return ;
}

hdu Train Problem I的更多相关文章

  1. hdu Train Problem I(栈的简单应用)

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

  2. HDU Train Problem I (STL_栈)

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

  3. HDU Train Problem I 1022 栈模拟

    题目大意: 给你一个n 代表有n列 火车,  第一个给你的一个字符串 代表即将进入到轨道上火车的编号顺序, 第二个字符串代表的是 火车出来之后到顺序, 分析一下就知道这,这个问题就是栈, 先进后出吗, ...

  4. HDU 1022 Train Problem I

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

  5. hdu 1023 Train Problem II

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

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

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

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

  8. Hdu 1022 Train Problem I 栈

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

  9. 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 ...

随机推荐

  1. Heap:左式堆的应用例(任意序列变单调性最小价值)

    首先来说一下什么是左式堆: A:左式堆是专门用来解优先队列合并的麻烦(任意二叉堆的合并都必须重新合并,O(N)的时间). 左式堆的性质: 1.定义零路经长:节点从没有两个两个儿子节点的路经长,把NUL ...

  2. kindeditor的简单使用

    上传到云: 一.引入kindeditor <%@ page language="java" contentType="text/html; charset=UTF- ...

  3. weblogic 安装和部署项目(原创)

    1.下载weblogic(含破解文件,土豪请支持正版,谢谢!) 2.安装如下图: 3.新建domain 4.打开weblogic Console 5.开始部署项目 6.部署成功

  4. 创建型模式之Strategy模式

    应用场景 实现某一个功能有多种算法或者策略,我们可以根据环境或者条件的不同选择不同的算法或者策略来完成该功能.如编写排序算法,可以将这些算法写到一个类中,在该类中提供多个方法,每一个方法对应一个具体的 ...

  5. CI框架获取post和get参数_CodeIgniter心得

    请参考:CI文档的输入类部分: $this->input->post() $this->input->get() ------------------------------- ...

  6. UVa 11524:In-Circle(解析几何)

    Problem EIn-CircleInput: Standard Input Output: Standard Output In-circle of a triangle is the circl ...

  7. git branch -D 大写的D 删除分支

    今天删除本地分支 git branch -d XXX 提示:  the branch  XXX is not fully merged 原因:XXX分支有没有合并到当前分支的内容 解决方法:使用大写的 ...

  8. rabbitMq使用(mac平台)

    1.下载 wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.5.3/rabbitmq-server-mac-standalone-3.5 ...

  9. CC2540开发板学习笔记(六)——AD控制(自带温度计)

    一.实验目的 将采集的内部温度传感器信息通过串口发送到上位机 二.实验过程 1.寄存器配置 ADCCON1(0XB4)ADC控制寄存器1 BIT7:EOC   ADC结束标志位0:AD转换进行中    ...

  10. HUE的时区问题

    转自 http://molisa.iteye.com/blog/1953390   我主要是根据这个说明调整的HUE的时区问题 在使用Cloudera Hue时遇到一问题: 1. 使用Sqoop导入功 ...