hdu 1022

原创 2015年07月08日 00:08:36

http://acm.hdu.edu.cn/showproblem.php?pid=1022

#include<iostream>
#include<cstring>
#include<stack>
using namespace std;
int main(){
  int n,i,j,k;
  bool io[20];
  char str[20];
  char str_1[20];
  while(cin>>n>>str>>str_1){
         stack<char>train;
         i=0;j=0;k=0;
         while(i<n){
         if(train.empty()||train.top()!=str_1[i]&&j<n){
              train.push(str[j++]);
              io[k++]=1;
         }
         else if(train.top()==str_1[i]){
            train.pop();
            io[k++]=0;
            i++;
         }
         else break;
         }
         if(train.empty()){
            cout<<"Yes."<<endl;
            for(i=0;i<k;i++)
                if(io[i])
                   cout<<"in"<<endl;
                else
                   cout<<"out"<<endl;
         }
         else
            cout<<"No."<<endl;
            cout<<"FINISH"<<endl;
            
  }
  return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

HDU 1022 Train Problem I 附详细思路

  • 2010年07月31日 14:33
  • 1KB
  • 下载

HDU-1022

As the new term comes, the Ignatius Train Station is verybusy nowadays. A lot of student want to get...

【HDU】1022

Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

hdu1022 Train Problem I_栈应用

Train Problem I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)...

hdu 1022 Train Problem I (栈)

As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to ge...

CSU-ACM2017暑期训练1-Debug与STL hdu1022-Train Problem I

题目链接:train problem 1 题目: Train Problem I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 6...

HDU 1022 Train Problem I (STL - 栈的使用)

Train Problem I Problem Description As the new term comes, the Ignatius Train Station is very ...

hdu1022(stack)

As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to ge...

hdu 1022 Train problem I(栈~~)

题意: 给定俩个个N长的串,第一个是源,第二个是目标。问能否得到目标序列,能的话再输出序列的进出情况。 分析: 比zoj 1259 稍微复杂点,但题目容易理解多了。。。^_^ 输出序列...
  • cqlf__
  • cqlf__
  • 2011年11月29日 21:02
  • 723

HDOJ/HDU 1022 Train Problem I(模拟栈)

Problem Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:hdu 1022
举报原因:
原因补充:

(最多只允许输入30个字)