hdu 1022

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;
}


posted @   wojiaohuangyu  阅读(6)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示