#include <iostream>
#include <stack>
#include <cstring>
using namespace std;
int main()
{
stack<char>s1;
stack<char>s2;
int n,i,j,k,a[10000];
char str1[100010],str2[100010];
while(cin>>n)
{
memset(str1,0,sizeof(str1));
memset(str2,0,sizeof(str2));
cin>>str1;
cin>>str2;
for(i=strlen(str2)-1; i>=0; i--)
s2.push(str2[i]);
for(i=0,j=0; i<strlen(str1); i++)
{
s1.push(str1[i]);
a[j++]=1;
while(!s1.empty()&&s1.top()==s2.top())
{
s1.pop();
s2.pop();
a[j++]=0;
}
}
if(s1.empty()&&s2.empty())
{
cout<<"Yes."<<endl;
for(i=0; i<2*n; i++)
if(a[i]==1)
cout<<"in"<<endl;
else
cout<<"out"<<endl;
}
else
{
cout<<"No."<<endl;
while(!s1.empty())
s1.pop();
while(!s2.empty())
s2.pop();
}
cout<<"FINISH"<<endl;
}
return 0;
}
hdu 1022 Train Problem I_栈的应用经典例题
最新推荐文章于 2017-02-24 11:07:13 发布