HDOJ1022(模拟栈)
Train Problem I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31758 Accepted Submission(s): 11976
#include <iostream>
#include <stack>
#include <string>
using namespace std;
const int MAXN=;
char o1[MAXN],o2[MAXN];
int n;
string op[MAXN];
int top;
int main()
{
while(cin>>n)
{
cin>>o1>>o2;
top=;
stack<char> st;
for(int i=,j=,len=strlen(o1);i<len;i++)
{
st.push(o1[i]);
op[top++]="in";
while(st.top()==o2[j])
{
st.pop();
j++;
op[top++]="out";
if(st.empty()) break;
}
}
if(st.empty())
{
cout<<"Yes."<<endl;
for(int i=;i<top;i++)
{
cout<<op[i]<<endl;
}
}
else cout<<"No."<<endl;
cout<<"FINISH"<<endl;
} return ;
}
HDOJ1022(模拟栈)的更多相关文章
- ACM/ICPC 之 用双向链表 or 模拟栈 解“栈混洗”问题-火车调度(TSH OJ - Train)
本篇用双向链表和模拟栈混洗过程两种解答方式具体解答“栈混洗”的应用问题 有关栈混洗的定义和解释在此篇:手记-栈与队列相关 列车调度(Train) 描述 某列车调度站的铁道联接结构如Figure 1所示 ...
- java 16 - 5 LinkedList模拟栈数据结构的集合
请用LinkedList模拟栈数据结构的集合,并测试 题目的意思是: 你自己的定义一个集合类,在这个集合类内部可以使用LinkedList模拟. package cn_LinkedList; impo ...
- hdu 4699 Editor 模拟栈
思路:刚开始用STL中的栈,一直RE……,之后改为手动模拟栈操作,在注意点细节就可以了!!! 代码如下: #include<cstdio> #include<cstring> ...
- 【DataStructure In Python】Python模拟栈和队列
用Python模拟栈和队列主要是利用List,当然也可以使用collection的deque.以下内容为栈: #! /usr/bin/env python # DataStructure Stack ...
- 第一回写的用arraylist模拟栈操作
package hashMap; import java.util.ArrayList; import d.Student; /** * 用ArrayList模拟栈操作 * @author zhuji ...
- HDOJ/HDU 1022 Train Problem I(模拟栈)
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot o ...
- c语言学习,模拟栈操作
1.stack.c模拟栈操作函数的实现 #include<stdio.h> #include<stdlib.h> ; static char *stack;//数据栈 ;//栈 ...
- KEILC51可重入函数及模拟栈浅析
MARK:文章中的红色部分是个人的理解. KEILC51可重入函数及模拟栈浅析 关键字:keilc51,模拟堆栈,可重入函数调用,参数传递,C?XBP,C?ADDXBP 摘要:本文较详细的介绍了kei ...
- 使用golang的slice来模拟栈
slice(切片):底层数据结构是数组 stack(栈):一种先进后出的数据结构 普通版的模拟写入和读取的栈 package main import "fmt" //栈的特点是先进 ...
随机推荐
- 阿里云+LAMP环境配置
1. 准备好一键Linux环境的脚本: http://dwz.cn/6Nlexm 2. 运行命令:# yum install lynx tree nmap sysstat lrzsz dos2unix ...
- spring 注入属性
一.注入对象类型的数据 1.配置文件 User类与UserService类均需要创建对象.所以都配置其相应的bean类,另外user需作为userService的属性注入,所以userService需 ...
- 爬虫-【selenium—Webdriver元素定位的八种常用方式
在使用selenium webdriver进行元素定位时,通常使用findElement或findElements方法结合By类返回的元素句柄来定位元素.其中By类的常用定位方式共八种,现分别介绍如下 ...
- 销售订单、外向交货单、交货 bapi
转自[http://www.cnblogs.com/elegantok/archive/2009/10/18/1585398.html]***********SALES ORDER INPUT CRE ...
- JVM性能优化, Part 5 Java的伸缩性
很多程序员在解决JVM性能问题的时候,花开了很多时间去调优应用程序级别的性能瓶颈,当你读完这本系列文章之后你会发现我可能更加系统地看待这类的问题.我说过JVM的自身技术限制了Java企业级应用的伸缩性 ...
- vue-router原理分析
本文整理总结自: https://zhuanlan.zhihu.com/p/27588422 单页面应用(SPA)的核心之一是: 更新视图而不重新请求页面, 实现这一点主要是两种方式: 1.Hash: ...
- SS中的三种样式来源:创作人员、读者和用户代理
CSS中的样式一共有三种来源:创作人员.读者和用户代理,来源的不同会影响到样式的层叠方式,很多第一次学习CSS的朋友,对这三种来源可能会存在一些困惑,下面我写一下自己的理解,若有错误的地方还请指正. ...
- 《python基础教程(第二版)》学习笔记 字典(第4章)
<python基础教程(第二版)>学习笔记 字典(第4章)创建字典:d={'key1':'value1','key2':'value2'}lst=[('key1','value1'),(' ...
- linux ps aux 结果解释
# ps aux | moreUSER PID %CPU %MEM VSZ RSS TTY STAT START ...
- 算法(Algorithms)第4版 练习 1.3.41
方法实现: //1.3.41 public Queue(Queue<Item> q) { Queue<Item> result = new Queue<Item>( ...