ACM详解(6)——栈收藏

堆栈是一种特殊的线性结构,后进先出,只能对栈顶元素操作,典型的操作入栈和出站。下面通过例子介绍基本用法。

题目:Train Problem

Problem Description

As the new term com es, the Ignatius Train Station is very busy nowadays. A l ot of student want to get back to school by train(because the trains in the Ignatiu s Train Station is the fastest all over the world ^v^). But here com es a problem, there is only one railway where all the trains stop. So all the trains com e in from one side and get out from the other side. For this problem, if train A gets into the railway first, and then train B gets into the railway before train A leaves, train A can't leave until train B leaves. The pictures below figure out the problem. Now th e problem for you is, there are at m ost 9 trains in the station, all the trains has a n ID(num bered from1 to n), the trains get into the railway in an order O1, your task is to determine whether the trains can get out in an order O2.

Input

The input contains several test cases. Each test case consists of an integer, th e num ber of trains, and two strings, the order of the trains com e in:O1, and the order of the trains leave:O2. The input is term inated by the end of file. More detai ls in the Sam ple Input.

Output

The output contains a string "No." if you can't ex change O2 to O1, or you sho uld output a line contains "Yes.", and then output your way in ex changing the ord er(you should output "in" for a train getting into the railway, and "out" for a train getting out of the railway). Print a line contains "FINISH" after each test case. M ore details in the Sam ple Output.

Sam ple Input

3 123 321

3 123 312

acm答案java_java-ACM详解(6)——栈 有答案版 全国软件设计大赛 参考试题相关推荐

  1. 2021年 第12届 蓝桥杯 第4次模拟赛真题详解及小结【Java版】

    蓝桥杯 Java B组 省赛决赛 真题详解及小结汇总[2013年(第4届)~2021年(第12届)] 第11届 蓝桥杯-第1.2次模拟(软件类)真题-(2020年3月.4月)-官方讲解视频 说明:大部 ...

  2. 2020年 第11届 蓝桥杯 第2次模拟赛真题详解及小结【Java版】

    蓝桥杯 Java B组 省赛真题详解及小结汇总[2013年(第4届)~2020年(第11届)] 注意:部分代码及程序 源自 蓝桥杯 官网视频(历年真题解析) 郑未老师. 2013年 第04届 蓝桥杯 ...

  3. 2021年 第12届 蓝桥杯 第3次模拟赛真题详解及小结【Java版】

    蓝桥杯 Java B组 省赛决赛 真题详解及小结汇总[2013年(第4届)~2021年(第12届)] 第11届 蓝桥杯-第1.2次模拟(软件类)真题-(2020年3月.4月)-官方讲解视频 说明:大部 ...

  4. 【人脸识别】人脸验证算法Joint Bayesian详解及实现(Python版)

    人脸验证算法Joint Bayesian详解及实现(Python版) Tags: JointBayesian DeepLearning Python 本博客仅为作者记录笔记之用,不免有很多细节不对之处 ...

  5. 稳扎稳打Silverlight(18) - 2.0视频之详解MediaElement, 开发一个简易版的全功能播放器...

    [索引页] [×××] 稳扎稳打Silverlight(18) - 2.0视频之详解MediaElement, 开发一个简易版的全功能播放器 作者:webabcd 介绍 Silverlight 2.0 ...

  6. 电商库存系统设计mysql_详解:电商系统库存逻辑的设计

    原标题:详解:电商系统库存逻辑的设计 本文主要对电商平台的订单系统相关库存逻辑进行了详细的阐述,一起来文中看看~ 一.库存的概念 电商的业务场景中订单的流程常常伴随着库存的变化:对于erp来说,库存可 ...

  7. 关于matlab兼容性win10系统,详解win10系统运行不了matlab10软件的办法

    今天小编分享一下win10系统运行不了matlab7软件问题的处理方法,在操作win10电脑的过程中常常不知道怎么去解决win10系统运行不了matlab7软件的问题,有什么好的方法去处理win10系 ...

  8. 你是真的“C”——详解C语言实现文件版通讯录

    详解C语言实现文件版通讯录

  9. 广联达2018模板算量步骤_老师傅带你学造价,广联达GTJ2018图文详解,小白也能学会的软件...

    在GTJ2018问世之前,土建造价人员有三个软件是必会的,一个是GGJ主打钢筋算量,一个是GCL主打土建算量,还有一个是GBQ主要是套定额用来计价的软件. 那时候如果计算一个工程的工程量,首先要用GG ...

  10. GitHub轻松阅读微服务实战项目流程详解【第二天:API网关的设计与实现】

    Two Day 1.配置文件精解 (1)bootstrap.yml文件 (2)nacos中关于gateway的配置信息 (3)applicaton.properties白名单配置 2.代码详解 (1) ...

最新文章

  1. java 默认字符集 iso_第二篇:JAVA字符编码系列二:Unicode,ISO-8859-1,GBK,UTF-8编码及......
  2. Linux Shell编程 test命令
  3. 用silverlight做动画-相机
  4. Android应用点击两次back退出
  5. r语言导入ggplot2_R语言 可视化之三大绘图系统概述:base、lattice和ggplot2 | 第7讲...
  6. hibernate之主键生成策略
  7. JQuery遍历控件的方法
  8. Python从零开始系列连载(32)——Python文件操作(下)
  9. Atitit. 如何判断软件工程师 能力模型 程序员能力模型  项目经理能力模型
  10. Linux基础知识汇总、有这一篇就够了(2021最新整理)
  11. OpenCV在图片和视频中的人脸检测
  12. linux 3g拨号,中兴MF637U 3G 联通 linux 拨号
  13. 关于事件驱动架构在工作中的一些想法及实践
  14. 拿什么拯救你,我的大规模杀伤性武器--Nokia!
  15. Java使用JDBC调用Mysql函数和存储过程
  16. 【蓝桥杯真题练习】STEMA科技素养练习题库 练习版004 持续更新中~
  17. bootstrap editable 动态改变列的编辑状态
  18. 计算机毕业设计选题 论文+源码+PPT
  19. mapreduce-全局排序 -夜幕思年华
  20. 惠普移动图形工作站 ZBook 15 G2 开箱 晒机 简评

热门文章

  1. realitycapture 3D建模软件
  2. android编程歌词显示,Android 音乐播放器实现歌词显示
  3. 34个有用的 JavaScript 库,现在就可以用起来
  4. OSGB数据的纹理压缩
  5. 马来西亚PHP项目_PHP大马的简单解密
  6. 修改本机域名localhost为任意你想要的名称
  7. JSP内置对象-out对象
  8. Python数据分析《黑客帝国》-一切都不是偶然
  9. RGB转YCbCr422_BT709颜色空间转换仿真
  10. linux 执行命令详细步骤,Linux命令行使用教程