Train Problem I
问题陈述:
杭州电子科技大学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的更多相关文章
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- HDU 1022 Train Problem I
A - Train Problem I Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u ...
- 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) ...
- hdu 1023 Train Problem II
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...
- sicily 1022. Train Problem
本题主要是出栈入栈顺序的问题 Home Problems My Status Standing <-> 1022. Train Problem Total: 2 ...
- Train Problem I(栈)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Train Problem I--hdu1022(栈)
Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- Train Problem II(卡特兰数+大数乘除)
Train Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 1023 Train Problem II(卡特兰数)
Problem Description As we all know the Train Problem I, the boss of the Ignatius Train Station want ...
- train problem I (栈水题)
杭电1002http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/ ...
随机推荐
- event和window.event
type:事件的类型,如onlick中的click:srcElement/target:事件源,就是发生事件的元素:button:声明被按下的鼠标键,整数,1代表左键,2代表右键,4代表中键,如果按下 ...
- php 实现传入参数的传出
类似于.net的out功能,php中可以使用&实现 如下示例: <?php$x=2; inOutFunction($x); function inOutFunction(&$x) ...
- python笔记之提取网页中的超链接
python笔记之提取网页中的超链接 对于提取网页中的超链接,先把网页内容读取出来,然后用beautifulsoup来解析是比较方便的.但是我发现一个问题,如果直接提取a标签的href,就会包含jav ...
- HTML+CSS学习
1.彻底弄懂CSS盒子模式(DIV布局快速入门) 2.在CSS中,BOX的Padding属性的数值赋予顺序为padding:10px; 四个内边距都是10px padding:5px 10px; 上下 ...
- FATE(费用背包,没懂)
FATE Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 居然因为交换错了好几把。。。。,还有坑点是num1可以大于num2
完数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- Qt之图标切分与合并(关键是使用QPixmap的copy函数来拷贝整张图片的某个区域)
有些时候会将多张有相同功能的图片绘制成一张,不管是使用或者绘制上都会方便很多.对美工与开发者来说也都是一件省事.省力.更省心的方式.二全其美,又何乐而不为呢... 例如:QQ等级 ...
- CSS开发经验
1.尽量用class来定义样式.尽量少使用 .div1 ul li{}这样的样式下去,因为如果li里面还有<div><ul><li>这些元素的话会造成干扰,应该给 ...
- MIT-scheme安装
下载地址: http://www.gnu.org/software/mit-scheme/ 下载windows版本,安装. The MIT-Scheme can be installed by jus ...
- 生成excel文件
java操作Excel最常用的开源组件有poi与jxl.jxl是韩国人开发的,发行较早,但是更新的很慢,目前似乎还不支持excel2007.poi是apache下的一个子项目,poi应该是处理ms的o ...