#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define max 100
char stack[max];
int top;
int empty()
{
if( top == 0 )
return 1;
return 0;
}
int main()
{
char in[max], out[max];
int n, j, q[max], l, i;
while( scanf( "%d", &n ) != EOF )
{
top = 0;
memset(stack, 0, sizeof(stack) );
memset(q, -1, sizeof(q) );
scanf( "%s", in );
scanf( "%s", out );
for( i = 0, j = 0, l = 0; j < n; )
{
if( empty() || stack[top-1] != out[j] )
{
stack[top++] = in[i];
q[l++] = 1;
i++; //最后总是没有AC的原因,忘了in 和out 都是不规律的变化
}
else
{
if( stack[top-1] == out[j] )
{
top--;
j++;
q[l++] = 0;
}
else
break;
}
}
if( empty() )
{
printf( "Yes.\n" );
for( i = 0; i < 2* n; i++ )
{
if( q[i] )
printf( "in\n" );
else
printf( "out\n" );
}
printf( "FINISH\n" );
}
else
{
printf( "No.\n" );
printf( "FINISH\n" );
}
}
return 0;
}
HDOJ 1022经典火车调度问题
最新推荐文章于 2018-08-02 20:48:56 发布