hdu-1022-栈】的更多相关文章

A - Train Problem I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1022 Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to…
 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 题目大意: 题目大概意思:有N辆火车,以序列1方式进站,判断是否能以序列2方式出栈.进站不一定是一次性进入,也就是说中途可以出站. #include <cstdio> #include <stack> #include <iostream> #include <algorithm> using namespace std; int main() { ],…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1022 Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45375    Accepted Submission(s): 16966 Problem Description As the new term come…
http://acm.split.hdu.edu.cn/showproblem.php?pid=1022 题意:给出火车的进站与出站顺序,判断是否可以按照给出的出站顺序出站. #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <vector> #include <algorithm> #include <ma…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 53352    Accepted Submission(s): 20006 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays…
传送门 Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes a pr…
#include<stdio.h> #include<stack> #include<string.h> #define N 20 using namespace std; int main() { stack<char>S; int n, i, j, k, a[N]; char s1[N], s2[N]; while(scanf("%d", &n) != EOF) { while(!S.empty())//清空栈 S.pop()…
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes…
题目大意: 给你一个n 代表有n列 火车,  第一个给你的一个字符串 代表即将进入到轨道上火车的编号顺序, 第二个字符串代表的是 火车出来之后到顺序, 分析一下就知道这,这个问题就是栈, 先进后出吗, 就是问你这个编号有没有可能出现, 有可能的话输出顺序,没可能直接输出No 题目分析: 我们用栈进行模拟, 先判断是否有这种出栈的可能, 假如有这种可能的话我们在模拟 一遍出栈的顺就行了. 每一次有新元素入栈我们就判断他是否雨 第二个字符串的第一个元素是否相等, 假如一样, 就让次元素出栈. 代码…
#include<iostream> #include<vector> #include<cstring> #include<string> #include<stack> #include<map> using namespace std; ]; /* 栈的应用 若in[i]==out[j]则先进栈后立即出栈,此时只需i++,j++: 若in[i]!=out[j]检查栈首是否为out[j],若是,则出栈,并j++,否则将in[i]入…
题目大意:有n辆火车,按一定的顺序进站(第一个字符串顺序),问是否能按规定的顺序出站(按第二个字符串的顺序出去),如果能输出每辆火车进出站的过程. 题目思路:栈的特点是先进后出,和题意类似,还有有一种情况是:开进来立马有开出去.并用vis[]数组的0,1标记进出站情况. 具体看代码 #include<cstdio> #include<cstring> #include<cmath> #include<queue> #include<algorithm&…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 51413    Accepted Submission(s): 19341 Problem Description As the new term comes, the Ignatius Train Station is very busy nowaday…
题意是给定火车进站的序列和出站的序列,问能否完成转换,若能输出过程. 和另一道以火车进站为背景的栈应用题类似,但增加了对于过程的输出,只需要多记录一下进出站顺序即可. #include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); ]; stack<char> q; ],go[]; while(cin >> n) { cin >> com…
Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^).…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 41471    Accepted Submission(s): 15510 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): 30245    Accepted Submission(s): 11434 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20521    Accepted Submission(s): 7712 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 18095    Accepted Submission(s): 6764 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays.…
Train Problem I 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all o…
Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes…
火车进站,模拟一个栈的操作,额外的栈操作,查看能否依照规定顺序出栈. 数据量非常少,故此题目非常easyAC. 直接使用数组模拟就好. #include <stdio.h> const int MAX_N = 10; char inOrder[MAX_N], outOrder[MAX_N], stk[MAX_N]; bool rs[MAX_N<<2]; int n; int main() { while (scanf("%d", &n) != EOF)…
题目链接 按序列a进栈,问能不能按序列b出栈. 遍历b,如果当前元素进过栈了,那么必须和栈顶元素相同.如果没进过栈则按a序列压栈,直到遇到当前元素. #include <iostream> #include <stack> #include <string.h> using namespace std; ],outo[]; ]; ]; int n; int main(){ int i,j; stack<char > s; while(scanf("…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1022 又是一道栈的练习,这次也是没有用到STL中的栈来实现.用来保存操作过程的数组(process[])一定要开得足够大(一开始开小了导致wa) #include <iostream> #include <string.h> #include <stdio.h> using namespace std; ; int main() { char o1[maxn], o2[ma…
转载:http://forum.byr.edu.cn/article/ACM_ICPC/51264 大家懂的,鉴于HDU用的是windows服务器,所以stack大小及其坑爹,稍微深一点的递归栈就会stack overflow. 通常的规避方法是用stack或者手写stack模拟栈的递归过程.这个极其蛋疼啊,而且被卡了STL也很得不偿失唉.(话说这一切都是基于非现场赛来说的,现场赛怎么会卡你这些玩艺儿.)   从Lost(庄立大神)那里学来一种规避栈溢出的方法. 在文件gui头处加上这么一句 #…
// hdu1022 这题算是我做的第一道栈的题目,之前看过栈的一些内容,做这道题的时候,可以模拟出过程,但是具体的代码不会写...所以决定练习一些栈和队列的问题,大概思路就是有三个数组和一个栈,先把第一个数组的第一个元素放进栈里,每次判断第二个数组和栈顶元素是否相等,如果相等就弹出,如果不相等就压入,大概就是这个思路.... #include <iostream> #include <stack> using namespace std; int main() { stack&l…
Expression Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 202    Accepted Submission(s): 61 Problem Description   As a shopkeeper of a restaurant,everyday ,dandelion's mother needs to calculat…
简单计算器 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19060    Accepted Submission(s): 6711 Problem Description 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值.   Input 测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30588    Accepted Submission(s): 11561 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays…
Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21736    Accepted Submission(s): 8232 Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays.…
#include<stdio.h> #include<string.h> #include<queue> #include<stack> using namespace std; int main() {    int n,m,i,j,k,t;    char s[30];    scanf("%d",&t);    while(t--) {     scanf("%d%s",&n,s);     if…