问题陈述:

  杭州电子科技大学HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1022

问题解析:

  栈(stack)的简单应用

代码详解:  

 #include <iostream>
#include <cstdio>
#include <stack>
#include <cstring> using namespace std; stack<int> s; int flag[]; int main()
{
int n, i, j, k;
char o1[], o2[];
while(~scanf("%d %s%s", &n, o1, o2)){
while(!s.empty()){
s.pop();
}
memset(flag, -, sizeof(flag));
j = k = ;
for(i=; i<n; i++) {
s.push(o1[i]);
flag[k++] = ;
while(!s.empty() && s.top()==o2[j]) {
s.pop();
flag[k++] = ;
j++;
}
}
if(j == n) {
cout << "Yes." <<endl;
for(i=; i<k; i++) {
if(flag[i]) {
cout << "in" <<endl;
}else {
cout << "out" << endl;
}
}
}else {
cout << "No." << endl;
}
cout << "FINISH" << endl;
}
return ;
}

参考博客:http://blog.csdn.net/lyhvoyage/article/details/18505997

转载请注明出处:http://www.cnblogs.com/michaelwong/p/4315668.html

Train Problem I的更多相关文章

  1. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  2. HDU 1022 Train Problem I

    A - Train Problem I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...

  3. Train Problem I 分类: HDU 2015-06-26 11:27 10人阅读 评论(0) 收藏

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  5. sicily 1022. Train Problem

    本题主要是出栈入栈顺序的问题 Home Problems My Status Standing <->           1022. Train Problem     Total: 2 ...

  6. Train Problem I(栈)

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  7. Train Problem I--hdu1022(栈)

    Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  8. Train Problem II(卡特兰数+大数乘除)

    Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. 1023 Train Problem II(卡特兰数)

    Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...

  10. train problem I (栈水题)

    杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/ ...

随机推荐

  1. img元素高度多出来的几像素

    HTML: <div class="test"><img src="body2.jpg" alt=""></d ...

  2. Mysql SlowLog 工具 pt-query-diglist

    工具地址:http://www.percona.com/doc/percona-toolkit/ 安装依赖工具 yum install perl-Time-HiRes 编译安装 perl Makefi ...

  3. 【6】使用nginx

    sudo vim /etc/nginx/nginx.conf user root; worker_processes 2; error_log /var/log/nginx/error.log; pi ...

  4. 【5】将服务部署到本机(Ubuntu14.04)

    首先,先将文件复制到指定的文件夹 我这里选择在/var下面新建一个www的文件夹来存放 复制BLOG文件夹的内容到www文件夹下 sudo cp -r /home/jakeychen/Jakey/Bl ...

  5. python保留指定文件、删除目录其他文件的功能(2)

    在(1)中脚本实现了保留指定文件的功能,但不能删除空目录,在此补上删除空目录的方法 def DeleteEmptyDir(path): for i in range(1,100): for paren ...

  6. android的编译和运行过程深入分析

    android的编译和运行过程深入分析 作者: 字体:[增加 减小] 类型:转载 首先来看一下使用Java语言编写的Android应用程序从源码到安装包的整个过程,此过程对了解android的编译和运 ...

  7. information_schema.optimizer_trace学习

    information_schema.optimizer_trace 用于追踪优化器的优化过程:通常来说这张表中是没有数据的,要想开户追踪要把 @@session.optimizer_trace='e ...

  8. mysql create routine 权限的一些说明

    1.如果用户有create routine 权限那么他就可以创建procedure | function . 2.如果用户创建了procedure | function 那么mysql 会自动赋予它对 ...

  9. socket浅谈

    1什么是socket? socket的英文原义是“孔”或“插座”.作为进程通信机制,取后一种意思. 通常也称作“套接字”,用于描述IP地址和端口,是一个通信链的句柄. (其实就是两个程序通信用的.)是 ...

  10. ActionBar-PullToRefreshLibs+沉浸式在部分手机上的布局错乱,目前知道的三星

    前段时间看见ActionBar-PullToRefreshLibs用来刷新很好看,配合4.4以上支持的沉浸式效果更佳,于是便想配合沉浸式+ActionBar-PullToRefreshLibs做出一个 ...