Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

hdu 4545

$
0
0

直接遍历,不能转换就删除






#include<stdio.h>
#include<string.h>
int link[30][30];
int main()
{
	int i,j,len1,len2,n,t,op=1;
	char s1[1100],s2[1100],ch1[2],ch2[2];
	scanf("%d",&t);
	while(t--)
	{
		memset(link,0,sizeof(link));
		scanf("%s%s",s1,s2);
         len1=strlen(s1);
		 len2=strlen(s2);
		scanf("%d",&n);
		while(n--)
		{
			scanf("%s%s",ch1,ch2);
			link[ch1[0]-'a'][ch2[0]-'a']=1;
		}
		for(j=0,i=0;i<len1&&j<len2;i++,j++)
		{			
		    while(s1[i]!=s2[j]&&link[s2[j]-'a'][s1[i]-'a']==0)
			{
				j++;
			}
			if(j>=len2)break;
		}
		printf("Case #%d: ",op++);
		if(i>=len1)
			puts("happy");
		else puts("unhappy");

	}
	return 0;
}


作者:aixiaoling1314 发表于2013-5-24 12:49:33 原文链接
阅读:64 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>