HDU 1022 Train Problem I
来源:互联网 发布:临高启明知乎 编辑:程序博客网 时间:2024/04/30 04:47
栈模拟
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <math.h>using namespace std;#define sf scanf#define pf printf#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)#define dbg(x) cerr << "Line:" << __LINE__ << " : " << #x << " = " << (x) << endl#define nMax 1000#define ll long longint n;string s1,s2;int in[nMax];int ans[nMax];char st[nMax];int top;void go() {top = 0;int i,j,m=0;i = 0;j = 0;int l = s1.length();//st[++top] = i;in[i]=1;i++;while(j < l) {if(top && s2[j]==s1[st[top]]) {ans[m++]=-1;top --;j++;}else {if(i==l) break;ans[m++]=1;st[++top]=i;in[i]=1;i++;}}if(j!=l) {pf("No.\n");pf("FINISH\n");}else {pf("Yes.\n");rep(i,m) {pf("%s\n",ans[i]==1?"in":"out");}pf("FINISH\n");}return ;}int main() {#ifndef ONLINE_JUDGEfreopen("in.txt","r",stdin);#endifwhile(cin >> n >> s1 >> s2) {go();}return 0;}
- HDU 1022 Train Problem I
- HDU-1022 Train Problem I
- HDU 1022 Train Problem I
- HDU 1022 ( Train Problem I )
- HDU 1022 Train Problem I
- HDU 1022 Train Problem I
- Hdu 1022 - Train Problem I
- HDU-1022:Train Problem I
- hdu 1022 Train Problem I
- hdu 1022 Train Problem I
- hdu-Train Problem I-1022
- hdu 1022 Train Problem I
- hdu 1022 Train Problem I
- hdu 1022 Train Problem I
- HDU 1022 Train Problem I
- hdu 1022 Train Problem I
- hdu 1022 Train Problem I
- HDU 1022Train Problem I
- UIActionSheet+Blocks
- 菜鸟的学习之路(9) — ArrayList类
- android layout 布局
- 最大公约数和最小公倍数
- python之路之python爬虫
- HDU 1022 Train Problem I
- 黑马程序员--数组
- 中庸之道
- JAVA系列-设计模式-原型模式
- HTML5学习笔记之canvas绘制圆形
- 黑马程序员-java面向对象的一些问题
- UVA - 658 It's not a Bug, it's a Feature!
- java【源码】成绩管理系统
- vc++数字图像处理 自适应二值化程序