标签:
/*Train Problem I<span style="font-size:18px;">#include<stdio.h>
#include<string.h>
#include<stack>
using namespace std;
int main()
{
stack<int>s;
int n;
char a[9],b[9];
while(~scanf("%d %s %s",&n,&a,&b))
{
int i,j,k=0,l=0,p=2,c[20];
s.push(a[0]);
c[1]=1;
while(l<n)
{
if(s.empty())
{
if(l<(n-1))
{
l++;
s.push(a[l]);
c[p]=1;
p++;
}
else
{
printf("Yes.\n");
for(i=1;i<=(2*n);i++)
{
if(c[i]>0)
printf("in\n");
else
printf("out\n");
}
printf("FINISH\n");
break;
}
}
while(!s.empty())
{
if(s.top()!=b[k])
{
l++;
if(l==n)
{
while(!s.empty())
{
s.pop();
}
printf("No.\n");
printf("FINISH\n");
break;
}
s.push(a[l]);
c[p]=1;
p++;
}
if(s.top()==b[k])
{
c[p]=0;
p++;
s.pop();
k++;
}
}
}
}
return 0;
}
</span>版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/qjt19950610/article/details/47211203