hdu1022】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 栈的模拟,题目大意是已知元素次序, 判断出栈次序是否合理. 需要考虑到各种情况, 分类处理. 常见错误:使用前未清空栈 使用STL思路较为清晰 代码附上, 欢迎各位大神指点~~ #include <cstdio> #include <stack> #include <iostream> #include <vector> using namespace s…
http://acm.hdu.edu.cn/showproblem.php?pid=1022 #include<iostream> #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<stack> using namespace std; ; int main() { //freopen("in.txt"…
#include <stdio.h>#include <string.h> int main(void){ int n,i,j,k,l; char o1[10],o2[10],s[10],h[20]; while(scanf("%d %s %s", &n, o1, o2)!=EOF) { memset(s,0,10); i=j=k=l=0; while(j<n&&i<n) { s[k++]=o1[i++]; h[l++]=1;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 题目大意: 车的进出站问题,先给出N个火车,再按序列一的方式进站,判断能否以序列二的方式出站,若能先输出"Yes.",再输出出站步骤,以FINISH结束,若不能,输出"No.",仍以FINISH结束. 思路: 直接模拟栈,注意细节! #include<iostream> #include<cstdio> #include<cstrin…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 42031    Accepted Submission(s): 15731 Problem Description As the new term comes, the Ignatius Train Station is very busy nowaday…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46887    Accepted Submission(s): 17593 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 解题报告: 思路: 就是维护好这个栈,只要它不是空,并且头部和ans相同,就一直出栈,直到不满足条件,然后入栈,重复比较.和Poj上一道题一样. 输出路径,记录在path中,出栈就是out,入栈就是in. #include <stdio.h> #include <string.h> #include <stack> using namespace std; ]; ];…
这个题我一开始是这么想的.. 爆搜所有可能的出栈序列 然后对输入进行匹配 这样我感觉太慢 然后我们可以想到直接通过入栈序列对出栈序列进行匹配 但是我犯了一个错误..那就是出栈序列一定到入栈序列里找.. 找不到的入栈,最后弹栈,弹不空的就是不合法序列 但是这里有一个逻辑不对..为什么最后才弹栈呢..为什么中间不能从非空栈中弹栈呢 所以,出栈序列要么和入栈序列匹配要么和已经入栈的栈顶匹配,要么安排入栈序列元素入栈, 如果入栈序列和入栈的栈顶都无法匹配且入栈序列无法入栈,那么匹配出错 对于5 1232…
ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜鸟之作,大牛勿喷,如有不当或补充之处,欢迎指出. 本建议书分为三个阶段,大一.大二.大三.大四暂没整理,一方面是大四要面临考验和找工作的问题,坚持继续acm的很少,另一方面,本人还没大四…… 下面以个人经验分析一下这三个阶段建议学习的内容和具体的训练计划. 正文: 大一(第一阶段): 大一是时间最充…
http://acm.hdu.edu.cn/showproblem.php?pid=1022 http://blog.csdn.net/swm8023/article/details/6902426此处分类题 hdu1022题copy代码 #include<iostream> #include<stack> #define max 100 using namespace std; int main() { stack<char>s; int n,i,j,k,result…