hdu-1022-栈
Train Problem I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 51329 Accepted Submission(s): 19314



3 123 312
in
in
in
out
out
out
FINISH
No.
FINISH
Hint
For the first Sample Input, we let train 1 get in, then train 2 and train 3.
So now train 3 is at the top of the railway, so train 3 can leave first, then train 2 and train 1.
In the second Sample input, we should let train 3 leave first, so we have to let train 1 get in, then train 2 and train 3.
Now we can let train 3 leave.
But after that we can't let train 1 leave before train 2, because train 2 is at the top of the railway at the moment.
So we output "No.".
#include<iostream>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
stack<char>a;
int main()
{
int n;
int vis[];
char s[],ss[];
while(cin>>n>>s>>ss&&n)
{
int j=,k=;
for(int i=;i<n;i++)
{
a.push(s[i]);
vis[k++]=;
while(!a.empty()&&a.top()==ss[j])
{
vis[k++]=;
a.pop();
j++;
}
}
if(a.empty())
{
cout<<"Yes."<<endl;
for(int i=;i<k;i++)
{
if(vis[i]==)
cout<<"in"<<endl;
else
cout<<"out"<<endl;
}
cout<<"FINISH"<<endl;
}
else
{
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
while(!a.empty())
a.pop(); }
return ;
}
hdu-1022-栈的更多相关文章
- HDU 1022 Train Problem I
A - Train Problem I Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- HDU 1022 火车进站【栈】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 题目大意: 题目大概意思:有N辆火车,以序列1方式进站,判断是否能以序列2方式出栈.进站不一定 ...
- HDU 1022 Train Problem I(栈的操作规则)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Ot ...
- Train Problem I hdu 1022(栈)
http://acm.split.hdu.edu.cn/showproblem.php?pid=1022 题意:给出火车的进站与出站顺序,判断是否可以按照给出的出站顺序出站. #include < ...
- hdu 1022 Train Problem I【模拟出入栈】
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1022 Train Problem I(栈模拟)
传送门 Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of st ...
- 栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022
#include<stdio.h> #include<stack> #include<string.h> #define N 20 using namespace ...
- HDOJ/HDU 1022 Train Problem I(模拟栈)
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...
- HDU Train Problem I 1022 栈模拟
题目大意: 给你一个n 代表有n列 火车, 第一个给你的一个字符串 代表即将进入到轨道上火车的编号顺序, 第二个字符串代表的是 火车出来之后到顺序, 分析一下就知道这,这个问题就是栈, 先进后出吗, ...
- hdu 1022 Train Problem I(栈)
#include<iostream> #include<vector> #include<cstring> #include<string> #incl ...
随机推荐
- 半平面交 (poj 1279(第一道半平面NlogN)完整注释 )
半平面交的O(nlogn)算法(转载) 求n个半平面的交有三种做法: 第一种就是用每个平面去切割已有的凸多边形,复杂度O(n^2). 第二种就是传说中的分治算法.将n个半平面分成两个部分,分别求完交之 ...
- C/C++预处理指令常见的预处理指令
C/C++预处理指令常见的预处理指令如下: #空指令,无任何效果 #include包含一个源代码文件 #define定义宏 #undef取消已定义的宏 #if如果给定条件为真,则编译下面代码 #ifd ...
- 20169219 使用Metaspoit攻击MS08-067实验报告
MS08-067漏洞介绍 MS08-067漏洞的全称为"Windows Server服务RPC请求缓冲区溢出漏洞",如果用户在受影响的系统上收到特制的 RPC 请求,则该漏洞可能允 ...
- mobiscroll_2.15.1
var opt_sex = { theme: 'ios', lang: 'zh', formatValue: function (d) { return d.join(','); }, customW ...
- Oracle 定时任务讲解
前几天,公司的job调度出现了问题,由于权限管的严,没有查看oracle 一些重要的数据字典,后面联系DBA,是由于数据库切换到备机时,参数设置不对,导致db job没有正常调度. 今天刚好有时间,想 ...
- IEnumerable、GetEnumerator、IEnumerator之间的关系。
了解了这些也就明白了遍历的原理,晚安. using System; using System.Collections; public class Person { public Person(stri ...
- CentOS 6.9下PXE+Kickstart无人值守安装操作系统
一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...
- newman的常用命令使用总结
前提:为了运行newman,你要确保系统中安装的Node.js版本是大于v6的. 命令常用选项: newman [optiions] -h:显示命令行帮助,包括选项列表和简单的使用案例. -v:显示当 ...
- HDU-1431-素数回文(暴力打表)
素数回文 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- 高版本sketch文件转成低版本的sketch
https://pan.baidu.com/s/1htmNERU 下载 该文件然后在放到高版本sketch文件的目录下,执行下面命令 chmod +x ./build.sh ./build.sh 文件 ...