现在的位置: 首页 > 综合 > 正文

hdu 1022 Train Problem I

2018年12月31日 ⁄ 综合 ⁄ 共 523字 ⁄ 字号 评论关闭

的简单题

 

#include<stdio.h>
#include<stack>
using namespace std;
int main()
{
    stack<char>Q;
	int i,n,a[200],j,num;
	char ch1[200],ch2[200];
	while(scanf("%d",&n)!=-1)
	{
		memset(a,-1,sizeof(a));
		scanf("%s%s",ch1,ch2);
		int len2=strlen(ch2);
		int len1=strlen(ch1);
          
		  i=0;j=0;
		  num=0;
		  while(j<len2)
		  {
			  Q.push(ch1[j++]);	
			  a[num++]=1;
			  while(!Q.empty()&&Q.top()==ch2[i])
			  {
				  Q.pop();i++;
				  a[num++]=0;
			  }
		  }
		  if(!Q.empty())
		  {
			  while(!Q.empty())
				  Q.pop();
			  printf("No.\n");
			  puts("FINISH");
		  }
		  else
		  {
			  puts("Yes.");
			  for(i=0;i<num;i++)
			  {
				  if(a[i]==1)
					  puts("in");
				  else puts("out");
			  }
			  puts("FINISH");
		  }
	}
	return 0;
}



 

【上篇】
【下篇】

抱歉!评论已关闭.