您的位置:首页 > 其它

HDU 1022

2012-03-07 13:14 134 查看
#include<stdio.h>
int main()
{
char a[10000],b[10000],s[10000];
int i,n,top,f[10000],j,count;
while(scanf("%d",&n)!=EOF)
{
getchar();
for(i=0;i<n;i++)
a[i]=getchar();
getchar();
for(i=0;i<n;i++)
b[i]=getchar();
getchar();
top=0;
s[top]=a[0];
j=0;
count=1;
f[0]=0;
for(i=1;i<=n;i++)
{
while(top>=0&&s[top]==b[j])
{
f[count]=1;
j++;
count++;
top--;
}
if(i!=n)
{
top++;
s[top]=a[i];
f[count++]=0;
}
}
if(j==n)
{
printf("Yes.\n");
for(i=0;i<2*n;i++)
if(f[i])
printf("out\n");
else
printf("in\n");
printf("FINISH\n");
}
else
printf("No.\nFINISH\n");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: