博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ 1022 模拟栈
阅读量:6225 次
发布时间:2019-06-21

本文共 2255 字,大约阅读时间需要 7 分钟。

Train Problem I

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17589    Accepted Submission(s): 6571

Problem Description
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.
 
Input
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 file. More details in the Sample Input.
 
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 your way in exchanging the order(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. More details in the Sample Output.
 
Sample Input
3 123 321 3 123 312
 
Sample Output
Yes. in in in out out out FINISH No. FINISH
 
简单栈模拟
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 int main() 7 { 8 stack
s; 9 vector
steps;10 char in[11],out[11];11 int i,j,n; 12 memset(in,0,sizeof(in));13 memset(out,0,sizeof(out));14 while(cin>>n>>in>>out)15 { 16 i=j=0;17 while(i
0;i--)47 s.pop();48 }49 return 0;50 }
View Code

 

9860133 2013-12-19 16:27:02 Accepted 0MS 316K C++

转载地址:http://pouna.baihongyu.com/

你可能感兴趣的文章
艾普联手OPENSTACK 打造公众云
查看>>
从线上卖到线下,秘籍在这里|千牛头条双11直播
查看>>
李飞飞:为什么计算机视觉对机器人如此重要?
查看>>
数据的价值 删除无用数据可降低风险
查看>>
2017年五大关键云趋势:容器、AI等
查看>>
JedisPool资源池优化
查看>>
数据库安全专家指出数据库取证仍然落后
查看>>
5G新规范:个人网络速度不低于下行100兆 上行50兆
查看>>
TensorFlow博客翻译——DeepMind转向TensorFlow
查看>>
信息化治理与北京治堵:疏图同归
查看>>
专访Dan Kohn:阡陌交迭,云原生布局开源生态构建及深度应用
查看>>
在Linux中添加普通新用户
查看>>
beego小技巧两则:通过命令行自定义端口和环境,url中带有中划线处理
查看>>
跨国引入强势技术 安全行业又添生力军
查看>>
吸烟损害健康,电子烟损害电脑,分分钟让电脑变砖
查看>>
市场井喷 到家服务将颠覆在线教育模式
查看>>
阿里云发布高IO实例 存储性能比通用型提升300%
查看>>
专访声网CEO赵斌:实时互联网正深入影响垂直领域
查看>>
中国人工智能学会通讯——新一轮人工智能发展的三大特征及其展望 1.1 新一轮人工智能发展的三个特征...
查看>>
超大规模数据中心运营商Switch公司申请IPO
查看>>