#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#define maxn 1001
using namespace std;
vector <int> vec;
class Queue{
private:
int data[maxn],fro,rear;
public:
Queue(){
fro=rear=0;
}
void Push(int a){
data[rear++]=a;
}
int Front(){
return data[fro];
}
void Pop(){
fro++;
}
bool Empty(){
return rear==fro?1:0;
}
};
class Stack{
private:
char data[maxn];
int top;
public:
Stack(){
top=0;
}
void Push(char a){
data[top++]=a;
}
char Top(){
return data[top-1];
}
void Pop(){
top--;
}
bool Empty(){
return top==0?1:0;
}
};
int main(){
int n;
char in[10],out[10];
while(cin>>n){
Stack st;
Queue Q;
scanf("%s %s",in,out);
for(int i=0,j=0;i<n;i++){
st.Push(in[i]);
Q.Push(1);
while(!st.Empty()&&st.Top()==out[j]){
j++;st.Pop();
Q.Push(0);
}
}
if(st.Empty()){
cout<<"Yes."<<endl;
while(!Q.Empty()){
if(Q.Front()==1)cout<<"in"<<endl;
else cout<<"out"<<endl;
Q.Pop();
}
}
else cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}
基本数据结构(栈,队,列)模版
最新推荐文章于 2024-07-18 17:57:16 发布