火车发车问题 - stack 出入栈问题

火车发车问题 - stack 出入栈问题

题目链接 - hdu1022

题目

As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world v). But here comes a problem, there is only one railway where all the trains stop. So all the trains come 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 the problem for you is, there are at most 9 trains in the station, all the trains has an ID(numbered from 1 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.
火车出入站示例
**H_On の 贴心翻译:**新学期到辣,伊格纳丢火车站最近会很忙。许多学生想坐火车回学校(因为德国医学世界第一!【不是】伊格纳丢火车站世界第一!),然后问题出现了,如果 A 车先进站,然后 B 车在 A 车出站之前也进站了,A 车就只能等 B 车出站以后才能离开了。下面的图片大概演示了一下这个尴尬的情况。然后日常推锅给你(工具人Acmer),现在最多有 9 趟火车会进站,所有的火车都有自己的 ID(数字 1 到 n ),火车进站次序是 O1 ,你的任务(功能)是判断按照出站次序 O2 能不能将火车全部发出。

输入

The input contains several test cases. Each test case consists of an integer, the number of trains, and two strings, the order of the trains come in:O1, and the order of the trains leave:O2. The input is terminated by the end of

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值