栈的练习 Train Problem I
来源:互联网 发布:java queue 编辑:程序博客网 时间:2024/05/16 08:29
Train Problem I
TimeLimit: 2000/1000 MS(Java/Others)Total Submission(s):6794
Problem Description
As the new term comes, the Ignatius Train Station is very busynowadays. A lot of student want to get back to school bytrain(because the trains in the Ignatius Train Station is thefastest all over the world ^v^). But here comes a problem, there isonly one railway where all the trains stop. So all the trains comein 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 intothe railway before train A leaves, train A can't leave until trainB leaves. The pictures below figure out the problem. Now theproblem for you is, there are at most 9 trains in the station, allthe trains has an ID(numbered from 1 to n), the trains get into therailway in an order O1, your task is to determine whether thetrains can get out in an order O2.
Input
The input contains several test cases. Each test case consists ofan integer, the number of trains, and two strings, the order of thetrains come in:O1, and the order of the trains leave:O2. The inputis terminated by the end of file. More details in the SampleInput.
Output
The output contains a string "No." if you can't exchange O2 to O1,or you should output a line contains "Yes.", and then output yourway in exchanging the order(you should output "in" for a traingetting into the railway, and "out" for a train getting out of therailway). Print a line contains "FINISH" after each test case. Moredetails in the Sample Output.
Sample Input
3 123321
3 123312
Sample Output
Yes.
in
in
in
out
out
out
FINISH
No.
FINISHFor the first Sample Input, we let train 1 get in, then train 2 andtrain 3. So now train 3 is at the top of the railway, so train 3can leave first, then train 2 and train 1. In the second Sampleinput, we should let train 3 leave first, so we have to let train 1get in, then train 2 and train 3. Now we can let train 3 leave. Butafter that we can't let train 1 leave before train 2, because train2 is at the top of the railway at the moment. So we output"No.".
Hint
Hint#include<stdio.h>
#include<string.h>
intnum1[11],num2[11],s[22],l[11];
intmain()
{
}
- 栈的练习 Train Problem I
- HDOJ 1022 Train Problem I
- (HDU)1022 Train Problem I
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- poj 3468 A Simple Problem with I…
- HDOJ 2101 A + B Problem Too
- hdu 1000 A + B Problem
- em的错误 <转载>
- hdu 1001 Sum Problem
- A Simple Math Problem
- matlab train 神经网络…
- POJ 1005 I Think I Need a Houseb…
- acm1001 Sum problem
- 文件I/O 函数
- This head I hold
-  
- .: I/O error
- 寒冰王座
- 水题 Parity
- 架构
- 水题 A Simple Task
- 有关栈的代码模板
- 栈的练习 Train Problem I
- 循环队列 约瑟夫问题
- hdu 1692 Destroy the Well of Lif…
- hdu 1157 Who's in the Middle(poj…
- 一个不错的资料网站 维基百科
- poj 2299 Ultra-QuickSort 归并排…
- poj 1804 (归并排序求逆序数)Bra…
- 今日免费精品文档<应届毕业生求职…
- 简单的二叉树 hdu 3791