栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022
- #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();
- scanf("%s%s", s1, s2);
- j = k = ;
- memset(a, , sizeof(a));
- for(i = ; i < n ; i++)
- {
- S.push(s1[i]);//入栈
- a[k++] = ;//进栈标记
- while(!S.empty() && S.top() == s2[j])//栈首相同
- {
- a[k++] = ;//出栈标记
- S.pop();//出栈
- j++;//j右移
- }
- }
- if(j == n)
- {
- printf("Yes.\n");
- for(i = ; i < k ; i++)
- if(a[i] == )
- printf("in\n");
- else
- printf("out\n");
- }
- else
- printf("No.\n");
- printf("FINISH\n");
- }
- return ;
- }
栈的简单应用 HDU 1022 http://acm.hdu.edu.cn/showproblem.php?pid=1022的更多相关文章
- HDU 4911 http://acm.hdu.edu.cn/showproblem.php?pid=4911(线段树求逆序对)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4911 解题报告: 给出一个长度为n的序列,然后给出一个k,要你求最多做k次相邻的数字交换后,逆序数最少 ...
- KMP(http://acm.hdu.edu.cn/showproblem.php?pid=1711)
http://acm.hdu.edu.cn/showproblem.php?pid=1711 #include<stdio.h> #include<math.h> #inclu ...
- HDU-4632 http://acm.hdu.edu.cn/showproblem.php?pid=4632
http://acm.hdu.edu.cn/showproblem.php?pid=4632 题意: 一个字符串,有多少个subsequence是回文串. 别人的题解: 用dp[i][j]表示这一段里 ...
- 待补 http://acm.hdu.edu.cn/showproblem.php?pid=6602
http://acm.hdu.edu.cn/showproblem.php?pid=6602 终于能够看懂的题解: https://blog.csdn.net/qq_40871466/article/ ...
- HDU 1702 队列与栈的简单运用http://acm.hdu.edu.cn/showproblem.php?pid=1702
#include<stdio.h> #include<string.h> #include<queue> #include<stack> #define ...
- HDU-1257 导弹拦截系统 http://acm.hdu.edu.cn/showproblem.php?pid=1257
Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高 ...
- http://acm.hdu.edu.cn/showproblem.php?pid=2579
#include<stdio.h> #include<string.h> #include<queue> #define N 110 int m, n, k, x1 ...
- KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594
riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...
- HDU 2544 最短路 http://acm.hdu.edu.cn/showproblem.php?pid=2544
//代码: //方法1:Dijkstra's Algorithm #include<stdio.h> #include<math.h> #include<string.h ...
随机推荐
- CF 366E Dima and Magic Guitar(最远哈密顿距离)
题目链接:http://codeforces.com/problemset/problem/366/E 题意:给出一个n*m的数字矩阵A,每个矩阵元素的范围[1,K].给出一个长度为s的数字串B,B的 ...
- MyBatis学习总结3-优化MyBatis配置文件
连接数据库配置优化 可以将数据库连接配置信息卸载conf.xml中,但是为了优化连接,专门写一个properties用于存数据库连接信息,然后在conf.xml中进行引用,里面包括数据库驱动,地址,用 ...
- Java关键字static、final使用小结
static 1. static变量 按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...
- open_table
/* Open a table. SYNOPSIS open_table() thd Thread context. table_list Open first table in list. acti ...
- 函数xdes_init
/**********************************************************************//** Inits an extent descript ...
- EASYUI+MVC4通用权限管理平台
通用权限案例平台在经过几年的实际项目使用,并取得了不错的用户好评.在平台开发完成后,特抽空总结一下平台知识,请各位在以后的时间里,关注博客的更新. 1.EASYUI+MVC4通用权限管理平台--前言 ...
- bzoj1567: [JSOI2008]Blue Mary的战役地图
将矩阵hash.s[0]忘了弄成0,输出中间过程发现了. hash.sort.判重.大概这样子的步骤吧. #include<cstdio> #include<cstring> ...
- bzoj1863: [Zjoi2006]trouble 皇帝的烦恼
白书原题.l边界又设错啦.一般都是错这里吧.注意为什么这里不能是l=0.(只是为了判断第一个和最后一个 #include<cstdio> #include<cstring> # ...
- Android development tools line_endings hacking
/******************************************************************** * Android development tools li ...
- Java [Leetcode 257]Binary Tree Paths
题目描述: Given a binary tree, return all root-to-leaf paths. For example, given the following binary tr ...